Execute

From Br Wiki
Jump to: navigation, search

The Execute statement causes a character string to be compiled and executed as though it were a Business Rules! command or instructions keyed directly from the keyboard.

Comments and Examples

One common use of the EXECUTE statement is copying from within a program. The following example purges records marked for deletion from an operator-chosen file (the file name is entered by the user):

00100 PRINT NEWPAGE
00110 PRINT "Enter FILENAME.EXT to be purged"
00120 LINPUT FILENAME$
00130 Execute "COPY "&FILENAME$&" TEMP.FYL -DN"
00140 Execute "FREE "&FILENAME$&" -N"
00150 Execute "RENAME TEMP.FYL "&FILENAME$&" -N"
00160 PRINT FILENAME$;" was successfully purged"

Execute statements do not restore the screen after execution. If you wish to restore the screen after an EXECUTE statement, insert an asterisk as the first character of the command string. Line 10 does not restore the screen, but line 20 does.

00010 Execute "DIR"
00020 Execute "*COPY OLDFILE NEWFILE"

Syntax

EXECUTE "[*]<command>"

Execute.png

Default

  1. Do not restore screen upon re-entry.

Parameters

The asterisk (*) prevents the screen from being restored upon re-entry.
The "command" is a required parameter in the EXECUTE statement and contains the commands you wish to execute.

Technical Considerations

  1. Relevant error conditions include the ERROR, Exit and IOERR conditions. All errors, including syntax errors, are passed back to the EXECUTE statement.
  2. Along with the CHAIN statement, the LOAD, SAVE, and REPLACE commands cannot be used in an EXECUTE statement because it is illegal to terminate a program with EXECUTE.
  3. INDEX and SORT may be initiated from within a program with the EXECUTE statement. Business Rules will not perform a CLEAR operation prior to beginning the INDEX or SORT process in this case. As there is not as much memory available, INDEX and SORT may run slowly from an EXECUTE statement, especially in large programs. When there is not enough memory available to complete the INDEX or SORT, Business Rules will generate error code 7607 (for INDEX) or error code 7811 (for SORT).
  4. EXECUTE may be specified as an immediate statement (without a line number), but Business Rules still considers it to be an active program.
  5. EXECUTE may be the subject of another EXECUTE statement.
  6. EXECUTE may be used to initiate express procedures and sub-procedure. See the Procedures chapter for more information.