EXECUTE Statement
Executes a TCL command from DataBasic. Data (including lists) can be passed between the command and the program.
EXECUTE functions in the same way as the PERFORM statement, except as described in Operation.
This function is provided for compatibility with other MultiValue systems.
Syntax
EXECUTE command
{[ STACKING || ,//IN. <
] inputExpr }
{[ PASSLIST
{inputListVar} ||
{[ RTNLIST
{outputListVar}
||
{[ CAPTURING ||
The optional clauses can be used in any order.
Syntax Elements
command An expression that evaluates to a string containing a single TCL command to be executed (including any parameters and options). Any terminal input required can be provided by appending it to command (as a dynamic array), by DATA statements that precede the EXECUTE statement, or by a STACKING or //IN clause.
STACKING inputExpr
,//IN. < inputExpr
Redirect data to the terminal input of the command being executed, where
Terminal input can also be provided by appending it to command (as a dynamic array), or by preceding DATA statements (see PERFORM). If none is provided by your program, any terminal input required by the command is requested from the command line.
PASSLIST {inputListVar}
Redirects a list (in the form of a dynamic array) from the variable inputListVar to the command specified in command. See PERFORM for details.
CAPTURING captureVar
,//OUT. > captureVar
Redirects output from the executed command to the variable specified by captureVar (see PERFORM for details).
RTNLIST {outputListVar}
Redirects a list generated by the command specified in command to the variable outputListVar as a dynamic array. See PERFORM for details.
SETTING settingVar
RETURNING settingVar
Specifies that error message numbers and their parameters are assigned to the variable
Note
This can be limited to error numbers only with the D3.SETTING compatibility switch matrix setting.Operation
EXECUTE functions in the same way as the PERFORM statement, except for the following:
-
The STACKING and ,//IN. < clauses provide an additional way of specifying data to be passed to the terminal input of the command being executed. This can also be done by appending the data to command as a dynamic array or by preceding the statement with one or more DATA statements (see Responses to Prompts).
-
Unlike the PERFORM statement, EXECUTE does not recognise the NULL keyword in a CAPTURING or ,//OUT. > clause; specifying NULL as captureVar will capture terminal output in a variable called NULL.
-
You cannot use PASSDATA and RTNDATA clauses with EXECUTE.
Examples
EXECUTE "WHO"
The command WHO is executed; the output is not redirected to a variable, so it is displayed on the user's screen.
EXECUTE "WHO"", //OUT. > X IF X<1>[1,8] # "0 SYSMAN" THEN PRINT "PROGRAM CAN ONLY BE RUN BY SYSMAN" STOP END
The command WHO is executed, with the output redirected to variable X. If X does not have a particular value, a message is displayed and the program terminates.
EXECUTE "COPY BP PROG1", //IN. < "BACKUPPROG1"
The command COPY is executed using the redirected string "BACKUPPROG1" instead of the user's terminal input.
EXECUTE "RUN BP TWOINPUT", //IN. < "ONE":CHAR(254):"TWO"
Assuming that the DataBasic program TWOINPUT has two INPUT statements: The first receives the data "ONE"; the second, the data "TWO".
EXECUTE "ED BP X", //IN. < "L22":CHAR(254):"EX", //OUT. > X
Two lines of data, "L22" and "EX", are redirected to the command ED. The output is redirected to variable X.
EXECUTE 'SELECT EMPFILE WITH SAL >= "10000"',//SELECT. > X EXECUTE 'LIST EMP.ADDR.FILE', //SELECT. < X
In the first EXECUTE statement the select list resulting from the SELECT statement is redirected to variable X. This list then used as input to the LIST command in the second EXECUTE statement.
EXECUTE 'DSM':@AM:'SP-LAB':@AM:'6':@AM:'Label printer':@AM:'FI':@AM
Executes DSM and creates a new despooler named SP-LAB, with the description 'Label printer'.