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} || ,//SELECT. < {inputListVar}]}
{[ RTNLIST {outputListVar} ||,//SELECT. >{outputListVar}]}
{[
CAPTURING || ,//OUT. > ]captureVar}
{[ SETTING || RETURNING ] settingVar }

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 inputExpr is a DataBasic expression that evaluates to the required terminal input. If required, inputExpr can contain multiple lines, separated by attribute marks.

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}

,//SELECT. < 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}

,//SELECT. >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 settingVar. See PERFORM for details.

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:

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'.