11.07.2015 Views

Caché ObjectScript Reference - InterSystems Documentation

Caché ObjectScript Reference - InterSystems Documentation

Caché ObjectScript Reference - InterSystems Documentation

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

DescriptionWHILE tests expression and then executes the block of code (one or more commands)between the opening and closing curly braces repeatedly, as long as expression evaluates toTRUE. If expression is not TRUE, block of code within the curly braces is not executed, andthe next command following the closing curly brace ( } ) is executed.The block of code within the curly braces can consist of one or more <strong>Caché</strong> Objectscriptcommands and function calls. This block of code may span several lines. Indents, line returns,and blank spaces are permitted within the block of code. Commands within this code blockand arguments within commands may be separated by one or more blank spaces and linereturns. However, each command keyword must be separated from its first argument byexactly one space.ArgumentsexpressionA test condition. It can take the form of a single expression or a comma separated list ofexpressions. For an expression list, <strong>Caché</strong> evaluates the individual expressions in left to rightorder. It stops evaluation if it encounters an expression that is FALSE. If all expressionsevaluate to TRUE, <strong>Caché</strong> executes the code commands. WHILE executes repeatedly, testingexpression for each loop. If any expression evaluates to FALSE, <strong>Caché</strong> ignores any remainingexpressions, and does not execute the code commands. It executes the next command afterthe code commands.ExampleMainloopSET x=1WHILE x < 10 {WRITE !," Looping",xSET x=x+1}WRITE !,"DONE"QUITreturns: “Looping1” through “Looping9”, then writes “DONE”.NotesWHILE and DO WHILEWHILEThe WHILE command tests expression before executing the loop. The DO WHILE commandexecutes the loop once and then tests expression.<strong>Caché</strong> <strong>ObjectScript</strong> <strong>Reference</strong> 157

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!