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> CommandsQUIT and LoopsA QUIT can be used to break out of a FOR loop, a DO WHILE loop, or a WHILE loop.If these loop structures are nested, the QUIT breaks out of the loop from which it was calledto the next enclosing loop.A QUIT cannot be used to break out of a nested IF block. When an IF block is nested withina loop structure (such as a FOR loop), a QUIT in the IF block breaks out of the enclosingloop as well.Implicit QUITIn the following cases, a QUIT command is not required, because <strong>Caché</strong> automatically issuesan implicit QUIT to prevent execution "falling through" to a separate unit of code.• <strong>Caché</strong> executes an implicit QUIT at the end of a routine.• <strong>Caché</strong> executes an implicit QUIT when it encounters a label with parameters. A labelwith parameters is defined as one with parentheses, even if the parentheses contain zeroparameters. All procedures begin with a label with parameters (even if no parameters aredefined). Many subroutines and functions also have a label with parameters.You can, of course, code an explicit QUIT in any of these circumstances.Behavior with DOWhen encountered in a subroutine called by the DO command, QUIT terminates the subroutineand returns control to the command following the DO command.Behavior with XECUTEWhen encountered in a line of code that is being executed, QUIT terminates execution ofthe line and returns control to the command following the XECUTE command. No argumentis allowed.Behavior with Loop StructuresWhen encountered in a loop structure, such as a FOR loop, QUIT terminates that loop andreturns control to the next command outside the range of the loop. In the case of nested loops,QUIT affects only the loop in which it occurs and any lower level loops that might be executedas a result of that loop. Higher level loops are not terminated.To control an indefinite FOR loop, you must include either a postconditioned QUIT or anIF command that invokes a QUIT. The QUIT within the IF terminates the enclosing FORloop. Without one of these QUITs, the loop will be an infinite loop and will execute endlessly.112 <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!