Nested Repeat loops

Richmond richmondmathewson at gmail.com
Sat Jun 21 02:33:43 EDT 2014


On 21/06/14 04:34, Dr. Hawkins wrote:
> On Fri, Jun 20, 2014 at 6:18 PM, Peter Haworth <pete at lcsql.com> wrote:
>
>> Wondering if anyone has an elegant way of exiting all the way out of a set
>> of nested repeat loops., e.g:
>>
> It's a badly needed language addition, and one of the things I want from
> Fortran.
>
> Then again, I actually used a GOTO in the software for my dissertation,
> after realizing it was the rare case one was called for, and had spent
> hours making parallel sets of code to avoid it.  (not to mention what I did
> with a trailing preposition in that last sentence!)
>
>

This is where some sort of "get out quickly" phrase is needed.

Yesterday one of my 12 year old 'victims'  was getting her feet wet with 
her first SWITCH statement,
and got badly bogged down, and we found that

exit switch

seemed to work a bit better than

break

the 'funny' thing is that the Dictionary (err: "Hitch Hiker's Guide to 
the Galaxy") says they are synonymous; but, as we linguists say 'no 2 
words are ever completely synonymous'.

I suppose a GOTO statement would be really good; especially as, although 
Livecode scripts
supposedly don't have line numbers, there are those numbers down the 
left-hand side :/

The only bother about those numbers is that every time one pops a bit of 
code into one's script they will refer to different places.

This sort of thing might not be bad:


put 1 into XX
repeat until XX>7
   do something
     put 1 into ZZ
         repeat until ZZ>7
           do something else
              put 1 into YY
                 repeat until YY>7
                     ask "What colour are you socks?"
                        if it contains "purple" then
                            goto %%%
                        end if
                        add 1 to YY
                  end repeat
               add 1 to ZZ
           end repeat
        add 1 to XX
end repeat
%%%

Richmond.





More information about the use-livecode mailing list