Dictionary: repeat

Mike Bonner bonnmike at gmail.com
Sat Jul 23 12:12:13 EDT 2016


There is no real difference between the 2 (repeat until, repeat with..)
but..

if you repeat with x = 1 to 20
add 1 to x -- will only repeat 10 times because the repeat increments 1,
and the add increments another
-- pretty much the same as appending step 2

end repeat

If you were to add -1 rather than 1, the loop would never end.  Each repeat
iteration adds 1, then its immediately subtracted again.The example from
your first post, and the example from your most recent are not the same.

On Sat, Jul 23, 2016 at 9:58 AM, Richmond <richmondmathewson at gmail.com>
wrote:

> Erm . . .
>
> So what is the difference between:
>
> on mouseUp
>   repeat with x = 1 to 20
>    --do something
>   end repeat
> end mouseUp
>
> &
>
> on mouseUp
>   put 1 into x
>     repeat until x > 20
>      --do something
>      add 1 to x
>    end repeat
> on mouseUp
>
> R.
>
>
> On 23.07.2016 18:02, [-hh] wrote:
>
>> Richmond wrote
>>
>>> "not recommended". If someone can explain in
>>> a way that makes reasonable sense ...
>>>
>> Predict the result of the following loop and
>> remove or not the "shiftkey-exit":
>>
>> on mouseUp
>>    repeat with x = 1 to 20
>>      -- add -1 to x  -- not recommended
>>      add -4/3 to x -- not recommended
>>      put x into fld 1
>>      if the shiftkey is down then exit repeat
>>    end repeat
>> end mouseUp
>>
>> "step" is especially useful in that you can do
>> rather `complicated' subdivisions in a very simple way:
>>
>> on mouseUp
>>    repeat with x = 1/13 to 1-1/13 step 1/13
>>      put cr & x after s
>>    end repeat
>>    put char 2 to -1 of s into fld 1
>> end mouseUp
>>
>> To the *precedence* of step in the repeat syntax see also:
>> http://forums.livecode.com/viewtopic.php?f=8&t=27523
>>
>>
>>
>>
>> --
>> View this message in context:
>> http://runtime-revolution.278305.n4.nabble.com/Dictionary-repeat-tp4706920p4706929.html
>> Sent from the Revolution - User mailing list archive at Nabble.com.
>>
>> _______________________________________________
>> use-livecode mailing list
>> use-livecode at lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>
>
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>



More information about the use-livecode mailing list