jhurley at infostations.com
Wed Jan 26 11:03:09 CST 2005
Being on the digest version of the list, I am coming in late on this one.
The thing that confused me in the beginning about Run Rev and numbers
is that they treated in a manner which depends on the context. For
example if you write:
put chars 1 to 4 of 123456 into theResult
Then theResult is 1234. Clearly 123456 is being treated as a string
And if you write:
put 123 & 456 into theResult
Then again these are treated as characters and theResult is 123456.
But if you write:
put chars 1 to 4 of 123*456 into theResult
Then you find the surprising thing that theResult is 46088
But if you write
put chars 1 to 4 of (123*456) into theResult
Then theResult is 4608, which is what you would expect. The
parentheses force an evaluation.
If you want to demand that the characters be treated as characters
and not numbers, use quotes. Then if you write:
put chars 1 to 4 of "123*456" into theResult
Then theResult is 123*, as you expect.
Moral: With flexibility comes responsibility.
But the value of being able to treat the number as a string is that
you can write a handler to format the number. For example, you can
format 1234467 as 1,234,567 or 1.23 * 10^6 or whatever.
More information about the use-livecode