docs.intersystems.com
Using Caché ObjectScript
Indirection, XECUTE Commands, and JOB Commands within Procedures
[Home] [Back] [Next]
InterSystems: The power behind what matters   
Search:    

Indirection, XECUTE Commands, and JOB Commands within Procedures
Name indirection, argument indirection, and XECUTE commands that appear within a procedure are not executed within the scope of the procedure. Thus, XECUTE acts like an implied DO of a subroutine that is outside of the procedure.
Indirection and XECUTE only access public variables. As a result, if indirection or an XECUTE references a variable x, then it references the public variable x regardless of whether or not there is also a private x in the procedure. For example:
 SET x="set a=3" XECUTE x ; sets the public variable a to 3
 SET x="label1" DO @x ; accesses the public subroutine label1
Similarly, a reference to a label within indirection or an XECUTE is to a label outside of the procedure. Hence GOTO @A is not supported within a procedure, since a GOTO from within a procedure must be to a label within the procedure.
Other parts of the documentation contain more detail on indirection and the XECUTE command.
Similarly, when you issue a JOB command within a procedure, it starts a child process that is outside the method. This means that for code such as the following:
    KILL ^MyVar
    JOB MyLabel
    QUIT $$$OK
MyLabel
    SET ^MyVar=1
    QUIT
In order for the child process to be able to see the label, the method or the class cannot be contained in a procedure block.


Send us comments on this page
Copyright © 1997-2019 InterSystems Corporation, Cambridge, MA