Alice Community

Alice Community (http://www.alice.org/community/index.php)
-   How do I...? (http://www.alice.org/community/forumdisplay.php?f=16)
-   -   Number string without decimal without "int as string" (http://www.alice.org/community/showthread.php?t=10029)

CellularDecay 04-10-2013 06:24 PM

Number string with no decimal without "int as string" (solved)
 
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.

CellularDecay 04-10-2013 10:04 PM

Number string with no decimal without "int as string" (solved)
 
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 ) )[/CODE]

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 )[/CODE]

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. :eek: 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.

x2495iiii 04-22-2013 03:30 PM

Not a bad solution.

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

Thanks.


All times are GMT -5. The time now is 03:21 AM.

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