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.

<strong>Caché</strong> <strong>ObjectScript</strong> CommandsNotesA block-oriented IF statement does not read or set the value of the $TEST special variable.If expression evaluates to TRUE, it executes the block of code within the curly braces,regardless of the setting of $TEST. If expression evaluates to FALSE, it continues executionafter the block of code enclosed in curly braces.An IF command can consist of an IF clause, one or more optional ELSEIF clauses, and anoptional ELSE clause. Only the block of code associated with one of these clauses can beexecuted. Successful execution of an IF clause or an ELSEIF clause completes the executionof the IF command.IF, ELSEIF, and ELSE clauses may use white space (line returns, indents, and blank spaces)freely. However, each IF and ELSEIF keyword and the first character of its expression mustbe on the same line, separated by one blank space. An expression can span multiple lines andcontain multiple blank spaces.IF with GOTO and QUITIf a GOTO or QUIT is encountered within an IF code block, program execution obeys thatstatement, with certain restrictions.A GOTO statement can jump to a location outside of the IF command, or within the codeblock of the current clause. A GOTO statement cannot jump into another code block: neithera code block that belongs to another clause of the current IF command, nor a code block thatbelongs to another IF, FOR, DO WHILE, or WHILE command.A QUIT command breaks out of the IF code block. However, if the IF code block is nestedwithin a loop structure, such as a FOR loop, the QUIT breaks out of that loop structure aswell.ExamplesIn the following example, the IF command is used to categorize responders into one of threegroups for subsequent processing. The three groups are females aged 24 or less, males aged24 or less, and either females or males aged 25 or more. In this example, the test expressionsuse the Binary Contains operator ( [ ). (See Operators in Using <strong>Caché</strong> <strong>ObjectScript</strong>.)56 <strong>Caché</strong> <strong>ObjectScript</strong> <strong>Reference</strong>

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

Saved successfully!

Ooh no, something went wrong!