Programing style
John Craig
jc at spl21.net
Thu Nov 16 19:10:11 EST 2006
Say we have a 10 digit number called tInt - 1234567890
repeat with i = length(tInt) - 3 to 1 step -3
We start at length(tInt) - 3 (position 7) and put a comma after the
character at position 7
This gives us 1234567,890
The next iteration (-3) takes us to position 4 - put in another comma;
Now we have 1234,567,890
Same again, takes us to position 1;
Now we have 1,234,567,890
The last iteration takes us to position -2. If we added a comma here,
it would appear near the end of the string!
So we add the condition;
if i > 0 then put "," after char i of tInt
the condition takes care of any strings which aren't exact multiples of 3.
:-)
JC
> it did, very nice code.
> Just don't understand the repeat header.
> "to 1 step -3"
> Thanks, Hershel
>
More information about the use-livecode
mailing list