Index

break

Prematurely exit the innermost enclosing foreach or while loop.

Arguments:
(none)

Example:
The following example executes a loop that contains two blocks of commands. Before executing the second section, the after command is used to determine whether it is too late in the day to continue with the loop. If it is then it exits the loop to the statement that prints "Done.".
 while(true) {
   ...
   if($after(12:30, UTC)) {
     break;
   }
   ...
 }
 print "Done.\n"
Context:
The break command is normally used to exit the middle of a loop. This is probably of most use in a foreach loop, where the lack of a continuation clause can otherwise be too constraining.

Martin Shepherd (9-Oct-1997)