11.07.2015 Views

Caché ObjectScript Reference - InterSystems Documentation

Caché ObjectScript Reference - InterSystems Documentation

Caché ObjectScript Reference - InterSystems Documentation

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

DescriptionFOR is a block-oriented command. The block of code that constitutes the loop is enclosedin curly braces. This block of code can contain line returns, indents, and blank spaces asneeded. When the loop concludes, execution continues with next command after the closingcurly brace. This next command may be on the same line or on the next line.The FOR command has two basic forms:• Without an argument• With an argumentFOR Without an ArgumentFOR without an argument executes the loop code block indefinitely. <strong>Caché</strong> repeats thecommands within the curly braces until it encounters a QUIT or GOTO command.The FOR keyword without an argument must be separated from the open curly brace thatfollows it by at least one space or tab.FOR With an ArgumentThe action FOR performs depends on the argument form you use.FORFOR variable=expr executes the looping commands once, setting variable to the value ofexpr.FOR variable=start:increment executes the looping commands indefinitely. On the firstiteration, <strong>Caché</strong> sets variable to the value of start. Each execution of the FOR commandincrements the variable value by the specified increment value. <strong>Caché</strong> repeats the commandsuntil it encounters a QUIT or GOTO command.FOR variable=start:increment:end sets variable to the value of start. <strong>Caché</strong> then executesthe looping commands based on the conditions described in this table:increment is positiveIf start > end, do not execute FOR. Whenvariable > (end-increment), or if <strong>Caché</strong>encounters a QUIT or GOTO command,stop.increment is negativeIf start < end, do not execute FOR. Whenvariable < (end-increment), or if <strong>Caché</strong>encounters a QUIT or GOTO command,stop.<strong>Caché</strong> evaluates the start, increment, and end values when it begins execution of the loop.Any changes made to these values within the loop are ignored and have no effect on thenumber of loop executions.<strong>Caché</strong> <strong>ObjectScript</strong> <strong>Reference</strong> 39

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

Saved successfully!

Ooh no, something went wrong!