EXECUTE


The EXECUTE or PERFORM statement allows the currently executing program to pause and execute any other UNIX/NT program, including another jBC program or a jBASE command.

 

COMMAND SYNTAX

EXECUTE|PERFORM expression {CAPTURING variable} {RETURNING|SETTING variable}
{PASSLIST expression} {RTNLIST {variable}}
{PASSDATA variable} {RTNDATA variable}

Data, Dynamic Arrays and lists can be passed to programs written in jBC. Screen output and error messages can be intercepted from any program.

 

SYNTAX ELEMENTS

The PERFORMed expression can be formed from any jBASE construct. The system will not verify that the command exists before executing it. The command is executed by a new Bourne Shell (sh) by default. The shell type can be changed by preceding the command with a CHAR(255) (or equivalently, @IM) concatenated with either "k", "c", or "s" to signify the Korn shell, C shell or Bourne Shell.

Variables used to pass data to the executed program should have been assigned to a value before they are used. Any variable name may be used to receive data.

CAPTURING variable
The capturing clause will capture any output that the executing program would normally send to the terminal screen and place it in the variable specified. Every newline normally sent to the terminal is replaced with a field mark in the variable.

RETURNING variable or SETTING variable
The returning and setting clauses are identical. Both clauses will capture the output associated with any error messages the executing program issues. The first field of the variable will be set to the exit code of the program.

PASSLIST variable
The PASSLIST clause allows jBASE programs to exchange lists or dynamic arrays between them. The variable should contain the list that the program wishes to pass to the jBASE program it is executing. The program to be executed should be able to process lists, otherwise the list will just be ignored. If the variable name is not specified then the clause will pass the default select list to the executing program.

RTNLIST variable
If the program executed sets up a list then the RTNLIST clause may be used to place that list into a specified variable. If the variable is omitted then the list is placed in the default list variable.

PASSDATA variable
The data in the specified variable is passed to another jBC program. The executing jBC program should retrieve the data using the COLLECTDATA statement.

RTNDATA variable
The RTNDATA statement returns any data passed from an executing jBC program in the specified variable. The executing jBC program should use the RTNDATA statement to pass data back to the calling program.

 

NOTES

The clauses may be specified in any order within the statement but only one of each clause may exist.

 

EXAMPLES

OPEN "DataFile" ELSE ABORT 201, "DataFile"
SELECT
PERFORM "MyProg" SETTING ErrorList PASSLIST
EXECUTE "ls" CAPTURING DirListing


jBC