Dictionary: repeat

-hh hh at hh.on-rev.com
Sat Jul 23 11:27:51 EDT 2016


The first case is a template where
x is an enumerator variable that is increased
(or decreased resp.) for you by LC.
It is not recommended to act on it because the
template is idiot-proof but NOT academic-proof.

In the second case x is your local variable that
you use as an enumerator.
This is even academic-proof.

[p.s. I'm academic too.]


Richmond 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-tp4706920p4706934.html
Sent from the Revolution - User mailing list archive at Nabble.com.




More information about the use-livecode mailing list