If your argument is a number, then you can just make the variable that you are using into a string.
Example:(t1 is a number)
t2 _ t1 asstring.
At least I think that's what it is.......
Last edited by GP1 (2011-12-27 23:19:56)
Offline
It's actually:
t2 _ t1 asString.
I believe you need the capital letter. (not asstring, asString)
To convert a string to a number:
t2 _ t1 asNumber
That will generate an error if the string has letters. To make it report 0 instead of error, use:
t2 _ t1 asNumberNoError.
Last edited by Greenatic (2011-12-28 12:14:25)

Offline
asNumberNoError is implemented in Boolean as well, so you can convert Booleans to numbers.
asString (by default) returns printString, a method which gives a representation of the object as a string. In other cases, you might want to use storeString, which gives a string that can later be used to reconstruct the object (it's valid Squeak code).
If you have a very large object, or want a shorter string, you can use printStringLimitedTo:, which acts like printString but cuts off the string at the given length.
Last edited by nXIII (2011-12-28 12:19:58)
Offline