Alice Community  

Go Back   Alice Community > Alice 2 > How do I...?

Reply
 
Thread Tools Display Modes
Number string with no decimal without "int as string" (solved)
Old
CellularDecay
Junior Member
 
Status: Offline
Posts: 7
Join Date: Jan 2013
Location: Kapolei, Hawaii
Default Number string with no decimal without "int as string" (solved) - 04-10-2013, 06:24 PM

So how would I create an integer string, without the "int as string" function?

My school is still using 2.0, and it does not have the "int as string" function. All the tutorials I've found use that function.

I tried round and floor, but the string conversion seems to add the decimal after the fact (even if the number given does not have a decimal, it still gets added).

Thanks, Tim

EDIT: Figured out a way to do it. See next message.

Last edited by CellularDecay; 04-10-2013 at 10:09 PM.
   
Reply With Quote
Number string with no decimal without "int as string" (solved)
Old
CellularDecay
Junior Member
 
Status: Offline
Posts: 7
Join Date: Jan 2013
Location: Kapolei, Hawaii
Default Number string with no decimal without "int as string" (solved) - 04-10-2013, 10:04 PM

Well, I thought of one way of doing it. Make a string list of the digits 0-9 and use the list to build the number string.

In my current case I needed to make a timer for class with both minutes and seconds (count down timer). So I first separrated the time into minutes and seconds variables, then I converted those to strings by pulling characters from my integerStrings list.

For the 2 digit seconds counter I used:
Code:
secondsString set value to ( ( item ( floor ( ( timer.seconds / 10 ) ) ) from timer.integerStrings ) joined with ( item ( ( timer.seconds - ( ( ( floor ( ( timer.seconds / 10 ) ) ) * 10 ) ) ) ) from timer.integerStrings ) )
Same thing with different variables for minutes.

When minutes dropped to single digit I used:
Code:
minutesString set value to ( item timer.minutes from timer.integerStrings )
Then I just combine them with a colon in the middle.

Don't know if anyone else is still using v2.0 without the "int as string" function, but if you are, this is a way to get your number strings without decimals.

Of course it would be easier of my school would just upgrade to a newer version with the function. I'm using v2.3 at home, and was quite surprised when I got to class and found my code would not load. So far that's the only incompatibility I've found (other than a bug in 2.0 that's fixed in 2.3). All the other stuff I've written has worked in class.

Last edited by CellularDecay; 04-10-2013 at 10:10 PM.
   
Reply With Quote
Old
x2495iiii
Super Moderator
 
x2495iiii's Avatar
 
Status: Offline
Posts: 3,508
Join Date: Dec 2008
Location: Somewhere in the Continental U.S.
Default 04-22-2013, 03:30 PM

Not a bad solution.

If other uses encounter this problem with any frequency, I'll pin this.

Thanks.


(')>
   
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



Copyright ©2024, Carnegie Mellon University
Alice 2.x © 1999-2012, Alice 3.x © 2008-2012, Carnegie Mellon University. All rights reserved.