Xecute

The XECUTE command makes an entry in the GT.M invocation stack and executes the argument as GT.M code.

The format of the XECUTE command is:

X[ECUTE]:tvexpr expr[:tvexpr][,...]

An explicit or implicit QUIT within the scope of the XECUTE, but not within the scope of any closer DO, FOR, XECUTE or extrinsic, returns execution to the instruction following the calling point. This may be the next XECUTE argument or another command. At the end of the code specified by the XECUTE argument expression, GT.M performs an implicit QUIT.

Because XECUTE causes run-time compilation in GT.M, and because it tends to obscure code, use XECUTE only when other approaches clearly do not meet your particular requirement.

Examples of XECUTE

Example:

GTM>Xecute "Write ""HELLO"""
HELLO
GTM>

This demonstrates a simple use of Xecute.

Example:

Set x="" For Set x=$Order(^%x(x)) Quit:x=""  Xecute x

This $ORDER() loop XECUTEs code out of the first level of the global array ^%x. Note that, in most cases, having the code in a GT.M source file, for example TMPX.m, and using a Do ^TMPX improves efficiency.