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.

XECUTEStart SET ops=$CHAR(27,21)READ !,"Total amount (or F1 for Calculator): ",amtIF $ZB=ops { DO Calc; . . .}Calc READ !,"Calculator"READ !,"Math operation on two numbers and/or variables."READ !,"First number or variable name: ",inp1READ !,"Mathematical operator (+,,*,/): ",opREAD !,"Second number or variable name: ",inp2SET doit="SET ans="_inp1_op_inp2XECUTE doitWRITE !,"Answer (ans) is: ",ansREAD !,"Repeat? (Y or N) ",inpIF (inp="Y")!(inp="y") { GOTO Calc+2 }QUITWhen executed, the Calc routine accepts the user inputs for the numbers and/or variablesand the desired operation and stores them as a string literal defining the appropriate SETcommand in variable doit. The XECUTE command references doit and executes the commandstring that it contains. This code sequence can be called from any number of points in theapplication, with the user supplying different inputs each time. The XECUTE performs theSET command each time, using the supplied inputs.XECUTE and ZINSERTYou use the XECUTE command to define and insert a single line of executable code fromwithin a routine. You can use the ZINSERT command from the programmer prompt to defineand insert by line position a single line of executable code into the current routine. You canuse the ZREMOVE command from the programmer prompt to delete by line position oneor more lines of executable code from the current routine.An XECUTE command cannot be used to define a new label. Therefore, XECUTE doesnot require an initial blank space before the first command in its code line. ZINSERT canbe used to define a new label. Therefore, ZINSERT does require an initial blank space (orthe name of a new label) before the first command in its command line.See Also• DO command• GOTO command• QUIT command• ZINSERT command• $TEXT function• $STACK special variable<strong>Caché</strong> <strong>ObjectScript</strong> <strong>Reference</strong> 175

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

Saved successfully!

Ooh no, something went wrong!