Commodore‎ > ‎BASIC‎ > ‎Keywords‎ > ‎

RUN

Keyword Abbreviation Token (hex) Version(s) Classification
RUN R{Shift+U} 8A 1.0 to 7.0 Command and Statement

 
Syntax   
RUN lineNumber ]
 ~ or ~
RUN fileName [ , D driveNumber ] [ { , | ON } U unitNumber ] ... [ , ItwoChar ] [ , R ] ...
 
Parameters Type Legal Value(s) Default Value Note(s)
lineNumber Unsigned Integer 0 ~ 63999 first line of program If used, must be a literal number.
fileName String  1~16 characters    BASIC 7 only.  Non-literal must be enclosed in parentheses () 
driveNumber Integer  0 or 1  BASIC 7 only.  Non-literal must be enclosed in parentheses ()
unitNumber Integer  8 ~ 11  BASIC 7 only.  Non-literal must be enclosed in parentheses () 
twoChar Char[2]  any    BASIC 7 only.  Must be two literal characters 
 
 
 
Purpose  
Program flow control.  Start program execution.

 
 
Remarks  
RUN is most typically entered without any parameters.  For those with v7.0, supplying a fileName (and sometimes a unitNumber) may occur on a regular basis.
 
If a fileName is givenRUN will first load the program (fileName) into memory.  Should the specfied fileName not be found on the device, a FILE NOT FOUND ERROR message will be generated.  The RUN fileName form, like all disk commands, updates the secret variable "DosFA" (sets it equal to unitNumber), and clears DS$.  See DLOAD for more information about parameters when a fileName is used.
 
Next, the RUN command perfors the equivalant of CLR : GOTO lineNumber (where lineNumber defaults to the first line of the program).  When a fileName is specified, execution always begins on the first program line; as it turns out, you can not supply both a fileName and a lineNumber... one or the other... if you try to specify both, you get SYNTAX ERROR.
 
Specifiying a lineNumber implies (but does not gaurantee) that one or more program lines will be skipped.  Skipping initial program line(s) is generally a bad idea.  Occassionaly it may be useful for debugging.  Much more useful for debugging are CONT and GOTO.  If lineNumber is specified, it must exist; otherwise an UNDEF'D STATEMENT ERROR is generated.
 
If you are into hard-core debugging/analysis, be sure to see the topic about Entering RUN Mode and of course the details of CLR.
 
This statement updates a secret variable "Run Mode" by setting it to 128.  It is secret because BASIC provides no way to read the value (except for machine-specific PEEK).
 
Example:
RUN : REM most typical

READY.
NEW

READY.
100 PRINT "ONE"
RUN 100
ONE

READY.
RUN 10

?UNDEF'D STATEMENT ERRROR
READY.
RUN "H.D.T.V."

SEARCHING FOR 0:H.D.T.V.
?FILE NOT FOUND ERROR
READY.
U = 10: F$ = "MP128.INI"

READY.
RUN (F$), U(U)
SEARCHING FOR 0:MP128.INI
LOADING
...  program starts running 
 
I almost forgot!  The "R" and "I" parameters (only allowed in BASIC 7.0) do noting.  If present, the "I" parameter must be immediately followed twoChars (any two two literal characters).  The I think is suppose to specifiy Read mode for the device, anyway you can use it multiply times if you like.
 
 
Compare With  
 
 
Contrast With  
 
See Also  

© H2Obsession, 2014
Comments