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.

<strong>Caché</strong> <strong>ObjectScript</strong> CommandsXECUTE with $TEXTIf you include a $TEXT function within an expression, it designates lines of code in theroutine that contains the XECUTE. For example, in the following program, the $TEXTfunction retrieves and executes a line.ASET H="WRITE !!,$PIECE($TEXT(HELP+1),"","",3)"XECUTE HQUITHELP;; ENTER A NUMBER FROM 1 TO 5Running routine A extracts and writes “ENTER A NUMBER FROM 1 TO 5”.Nested Invocation of XECUTE<strong>Caché</strong> <strong>ObjectScript</strong> supports the use of XECUTE within an XECUTE argument. However,you should use nested invocation of XECUTE with caution because it can be difficult todetermine the exact flow of processing at execution time.Execution Time for Commands Called by XECUTEThe execution time for code called within XECUTE can be slower than the execution timefor the same code encountered in the body of a routine. This is because <strong>Caché</strong> compiles sourcecode that is specified with the XECUTE command or that is contained in a referenced globalvariable each time it processes the XECUTE.Implementing Generalized OperationsA typical use for XECUTE is to implement generalized operations within an application.For example, assume that you want to implement an inline mathematical calculator that wouldallow the user to perform mathematical operations on any two numbers and/or variables. Tomake the calculator available from any point in the application, you might use a specificfunction key (say, F1) to trigger the calculator subroutine.A simplified version of the code to implement such a calculator might appear as follows.174 <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!