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.

When a block ends, as indicated by a line at with fewer prefix periods than the current line,<strong>Caché</strong> <strong>ObjectScript</strong> issues an implicit QUIT that exits the block of code, and resumes executionat the previous level. You can code an explicit QUIT command as the last line of the block,but it is not necessary.VariablesAll code blocks share the same local variables. Therefore, you can supply a value to an innerblock by setting a variable before invoking that code block level. Similarly, any results fromthe execution of an inner block can be preserved at the next higher level by changing thevalues of shared local variables.The $TEST special variable is handled differently by argumentless DO, than by a DO commandcalling a subroutine or procedure. The argumentless DO preserves the initial value of$TEST during execution of its code block. If the block includes a command (such as a legacyIF command, or a timed OPEN) that resets the value of $TEST, this change is not passedback to the next higher level.ArgumentspcAn optional postconditional expression. <strong>Caché</strong> executes the command if the postconditionalexpression is true (evaluates to a non-zero numeric value). <strong>Caché</strong> does not execute the commandif the postconditional expression is false (evaluates to zero). For further details, referto Command Postconditional Expressions in Using <strong>Caché</strong> <strong>ObjectScript</strong>.blockcommandOne or more <strong>Caché</strong> <strong>ObjectScript</strong> commands executed as a code block. Each blockcommandline (including comments and blank lines) must be prefixed by one or more periods, asspecified in the Code Block Syntax.ExamplesDO (legacy version)Note:Note that the following examples use the legacy versions of the IF and FOR commands.Commands that delineate a block of code using curly braces (such as thecurrent version of IF and FOR) do not need to use the argumentless DO, and arenot compatible with period prefix syntax.In the following example, the two argumentless DO commands each invoke a block of code.Which DO is executed and, consequently, which block is invoked depends on which operationthe user requests, as determined by the IF command. In each case, the result is passed back<strong>Caché</strong> <strong>ObjectScript</strong> <strong>Reference</strong> 743

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

Saved successfully!

Ooh no, something went wrong!