Yazoo ---> Online Help Docs ---> Yazoo scripting ---> Loops and if blocks

break

There is no break statement in Yazoo. We can however jerry-rig something that does pretty much the same. The trick is to put braces -- with no code marker or semicolon -- around the code we eventually want to escape from. Within those braces, a return statement will simply escape from the bracketed code and continue with what follows. For example:


    {
       for counter in [1, 10]
           print(counter)
           if input() == 'q', return, endif
       endf
    }
   

The disadvantage is that if we are running a function, we cannot do a direct return from the function within the bracketed code: we can only break. On the upside, we have a lot of latitude in choosing where to put the braces. We are not restricted to escaping from loops, and if we do use them inside loops it does not have to be to the next-outermost for or while.


Prev: for   Next: Sets


Last update: July 28, 2013

Get Yazoo scripting language at SourceForge.net. Fast, secure and Free Open Source software downloads