Repeat Loop
Robert Brenstein
rjb at robelko.com
Sat Nov 21 06:45:13 EST 2009
On 20.11.09 at 15:13 -0500 Schwartz, Jonathan L. apparently wrote:
>Has anyone had a problem with the following?
>
>on mouseUp
> repeat with n = 0 to 1 step 0.1
> put n&"," after aList
> end repeat
> put aList
>end mouseUp
>
>Returns
>0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1,1.1,
>
>However,
>
> on mouseUp
> repeat with n = 0 to 2 step 0.1
> put n&"," after aList
> end repeat
> put aList
>end mouseUp
>
>Returns
>0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1,1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9,2,
Avoid using real numbers like this. You run into rounding/precision
issues. Try sth like:
on mouseUp
put empty into aList
repeat with n = 0 to 20
put (n/10) & comma after aList
end repeat
put aList
end mouseUp
More information about the use-livecode
mailing list