exit repeat and nested repeats

Richard Gaskin ambassador at fourthworld.com
Thu Aug 1 16:30:10 EDT 2013


Andrew Kluthe wrote:
> How does exit repeat handle nested repeats? Does it exit the parent repeat
> if called from a child repeat in two repeats that are nested in a handler?
>
>          repeat for each key sKey in sData
>             repeat for each key sKey2 in sData[sKey]
>                exit repeat
>             end repeat
>          end repeat

"Exit repeat" exits only the loop that statement is in.

You can exit to handler with "exit <handlerName">, or exit all script 
execution with "exit to top".

But if you need to exit a specific repeat structure, you'll have to add 
an "exit repeat" for each level you want to exit.

At once of the RevCons a few years ago Robert Cailliau proposed adding 
an option to name repeats so we can exit any of them from any level. 
Might be nice to see that one day.

--
  Richard Gaskin
  Fourth World
  LiveCode training and consulting: http://www.fourthworld.com
  Webzine for LiveCode developers: http://www.LiveCodeJournal.com
  Follow me on Twitter:  http://twitter.com/FourthWorldSys




More information about the use-livecode mailing list