RUN¶
Syntax¶
Versions: 8K, Extended, Disk
Purpose¶
To execute the current program in memory, or to load and execute a program from disk.
Remarks¶
The RUN statement has several forms:
RUN - Executes the current program starting at the lowest line number. All variables are cleared and files are closed before execution begins.
RUN line-number - Executes the current program starting at the specified line number. All variables are cleared and files are closed.
RUN "filename" - (Disk BASIC only) Loads the specified program file from disk and executes it. The current program is replaced and all variables are cleared.
When RUN is executed: - All variables are reset to zero or empty strings - All open files are closed (unlike STOP, which keeps files open) - All FOR/NEXT loops are cleared - All GOSUB return addresses are cleared - DATA pointers are reset to the first DATA statement
Example¶
RUN
RUN 100
RUN "PROGRAM.BAS"
10 PRINT "Starting..."
20 RUN 50
30 PRINT "This line is skipped"
40 END
50 PRINT "Execution starts here"
Notes¶
- RUN always clears all variables, even when starting at a specific line
- To resume execution without clearing variables, use GOTO instead
- File extension defaults to .BAS if not specified
See Also¶
- CHAIN - To call a program and pass variables to it from the current program
- CLEAR - To set all numeric variables to zero and all string variables to null; and, optionally, 'to set the end of memory and the amount of stack space
- COMMON - To pass variables to a CHAINed program
- CONT - To continue program execution after a Control-C has been typed, or a STOP or END statement has been executed
- END - To terminate program execution, close all files and return to the BASIC prompt
- GOTO - Branch unconditionally to a specified line number
- LOAD - To load a file from disk into memory
- NEW - To delete the program currently in memory and clear all variables
- STOP - To terminate program execution and return to the BASIC prompt
- SYSTEM - Exits MBASIC and returns to the operating system