qb45advr.hlp (Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
RUN Statement Details
  QuickSCREEN      Details      Example      Contents      Index
──────────────────────────────────────────────────────────────────────────────
RUN Statement Details
 
Syntax
  RUN [{linenumber | filespec}]
 
  Argument      Description
  linenumber    The numeric label of the line where execution begins.
                If no argument is given, execution begins at the first
                executable line.
  filespec      A string expression naming the program file to load
                and run. The current program is cleared from memory
                before the specified program is loaded.
 
The line where execution begins must be in the module-level code. Therefore,
a RUN statement in a SUB or FUNCTION procedure must point to labels at
module level. If no line label is given, execution always starts with the
first executable line of the main module.
 
During compilation, if linenumber cannot be found in the module-level
code, compilation halts and the error message Label not defined appears.
 
Program lines can have line numbers or alphanumeric labels, such as
OpenWindow:. If an alphanumeric label is the target of a RUN statement,
execution halts, and the error message "Type mismatch" appears. Note
that the QuickBASIC syntax checker does not warn you if you give the
RUN statement an alphanumeric label instead of a line number.
 
You do not need to specify the file name extension in filespec. The .BAS
extension is assumed in the QuickBASIC environment. QuickBASIC assumes
the .EXE extension for compiled, stand-alone programs. If the program
you wish to run has a different extension, you must give the extension.
If the program name has no extension, the file name given must end with a
period. For example,
 
  RUN "CATCHALL"
 
would execute CATCHALL.EXE from a BC-compiled program, and CATCHALL.BAS
from within QuickBASIC.
 
Programs running within the QuickBASIC environment must call only QuickBASIC
program files. The file is loaded and run as if it were a QuickBASIC
program; if it is not in the QuickBASIC program format, execution halts.
The error message that appears varies, depending on the file's contents.
Likewise, programs compiled with BC must not invoke QuickBASIC source files,
as these run only in the QuickBASIC environment.
 
An executable file need not have been written in QuickBASIC. Any executable
file may be run.
 
When running a program under QuickBASIC, if an executable file matching the
file name in commandline cannot be found, the error message "File not found"
appears, and control returns to QuickBASIC. When running a program compiled
by BC, the error message "File not found in module programname" appears,
and control returns to DOS.
 
When the invoked program completes execution, control does not return to the
invoking program. If the invoking program ran outside QuickBASIC, control
returns to DOS. If the invoking program ran under QuickBASIC, control
returns to QuickBASIC.
 
If you edit a QuickBASIC program containing a RUN statement, then run the
program before saving the changes, QuickBASIC asks if you wish to save the
new version of the program before RUN clears it from memory.
 
RUN closes all files and clears program memory before loading the designated
program. The BC compiler does not support the R option from BASICA. (The
R option keeps all open data files open.) If you want to run a different
program, but leave open files open, use the CHAIN statement.