Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

If used outside of a do() or forEach() function then break() will cause the analysis for the Stream Set to stop as though a stop() function was called (but will produce an error message rather than a warning message). No records will be saved for that Stream Set.

Syntax

break()

Examples

In this first example, forEach() is used to iterate over a list of manager names until "Wally" is found, at which point we can stop looking. Used in a string-valued field on a stream, this would output the value "Found Wally!" into the stream record in that field.

Note how $outputString is still available after the call to break() has been made and the do() routine has terminated.


Code Block
do(
   $outputString = "Can't find Wally..."
   
   forEach($manager, $managersList
   	  
	  if($manager = "Wally",
   	     do(
		    $outputString "Found Wally!"
   	        break()
		 )
   	  )
   ),
   
   //output the result
   $outputString
)   

...

Note how $outputString is still available after the call to break() has been made.


The above example (somewhat contrived, see included() or subset() for a more practical solution) example shows how break() can be useful when iterating over lists, if you don't need knowledge of all of the elements.

...

Note that the call to break() exits both the ( inner ) do() routine, and the ( outer ) forEach() - but not the current stream processing cycle.

...