Run

From Br Wiki
Jump to: navigation, search

The Run (RU) command begins execution of a program. When RUN is used to redirect printer output to a file or screen (RUN> filename) the redirection is now stopped only when the system returns to READY mode (when no programs or procedures remain active). This allows redirection to work with a procedure file that contains multiple RUN commands. Previously, the redirection remained active only until the next RUN command was issued.

Comments and Examples

RUN sets all variables to zero (or zero length) and begins executing at the lowest line number of the program. Open files stay open. Execution halts and an error message is displayed on the status line when an error occurs during program execution.

A running program stops when it reaches a STOP, END, or CHAIN statement within the program; all open files close (except when the optional FILES parameter is used in a CHAIN statement). A running program pauses when it reaches a PAUSE statement or when you press the Ctrl-A key combination. To resume execution, enter a GO command (see the options for the GO command in the GO section of this chapter).

The following command begins execution of the program in memory at line 350:

RUN 350

The next command executes the program in memory and sends all printer output to the file REPORT. The use of the double redirection arrow (>>) causes the output to be appended to the end of REPORT (rather than to overwrite it):

RUN >>REPORT

The command below begins execution of the program in memory and directs printer output to the screen:

RUN >CON:

The following command loads and begins execution of the program SCORE. All TRACE output is sent to the printer.

RUN B:SCORE TRACE PRINT

Syntax

RUN <file name> [ TRACE [PRINT]][...] [{STEP|PROC|<line number>|>[>]<file name>}[...]

Run.png

Defaults

  1. RUN the program currently in memory.
  2. Send TRACE output to the screen.

Parameters

"File-name" is the name and path of the file you wish to run. BR to see that the named file exists, then performs a CLEAR operation and loads and begins executing the specified file. File names which are the same as any of RUN's parameters (TRACE, PRINT, STEP or PROC) cannot be specified with the RUN command. Also, file names that are also numbers cannot be specified with RUN (the number will be interpreted as a "line-num" parameter -see below) unless the extension is also specified (i.e., RUN 123.BR). It is important to note that the system will always clear current memory and load the specified file, even if that file is currently in memory -thus the potential exists for losing unstored program lines.
"TRACE" displays the line number of each line as it is being executed. Unlike STEP, it does not cause the program to pause before executing each statement. This parameter is very useful for debugging purposes. To turn TRACE off, you must interrupt BR (Ctrl-A) and use GO RUN to continue execution.
"PRINT" sends TRACE output to an attached printer.
"STEP" pauses the program before each statement is executed. The line number field in the status line tells you the next line number to be executed. That line is executed and the next line number appears when <CR> is pressed. STEP is useful for debugging of programs, as it allows you to closely follow the program's flow.

The RUN command with the "PROC" parameter works only within a procedure file. It instructs BR to accept input from the procedure file for all INPUT, LINPUT, and RINPUT statements. Normally the input for these statements would come from the keyboard. The RUN PROC option has no effect on INPUT FIELDS or RINPUT FIELDS statements.

If you wish to start running the program from a point other than the beginning, you can use "line-num" to specify the first line of execution.

"File_ref saves to a file all program output that normally goes to the printer. Use of one redirection arrow (>) causes output to overwrite the contents of the specified file. Two redirection arrows (>>) cause the output to be appended to the end of the specified file.

The >file-ref can also redirect printer output to other communications devices. To send output to the screen, for example, use:

RUN >CON:

To send it to whatever device is connected to the first communications port, use:

RUN >AUX:

These strings must be translated with the SUBSTITUTE specification for BR or Linux versions. BR sends all program results to the specified file-ref location until you enter another RUN command.

Technical Considerations

  1. BR closes a procedure before executing the last line. Thus when RUN file-ref is included as the last line, there is a clean trade-off in the number of open files on the system. But RUN PROC cannot be used as the last line because the procedure will be closed before the program starts to look for data in the procedure (an easy solution is to add a blank line or comment line after the RUN PROC command).
  2. The use of RUN PROC does not alter the forward slash's (/) capability of terminating INPUT, LINPUT and RINPUT statements. See the INPUT statement for additional information.
  3. RUN >file-ref remains in effect until another RUN command is issued. Output redirected to a file is not accessible until the file is closed by another RUN command.