Home > CBM > BASIC > Keywords > Run
180 Subpages: (divide), (equal), (less), (minus), (more), (multiply), (plus), (power), Abs, And, Append, Asc, Atn, Auto, Backup, Bank, Begin, Bend, Bload, Boot, Box, Bsave, Bump, Catalog, Char, Chr, Circle, Close, Clr, Cmd, Collect, Collision, Color, Concat, Cont, Copy, Cos, Data, Dclear, Dclose, Dec, Def, Delete, Dim, Directory, Dispose, Dload, Do, Dopen, Draw, Ds, Ds string, Dsave, Dverify, El, Else, End, Envelope, Er, Err, Exit, Exp, Fast, Fetch, Filter, Fn, For, Fre, Get, Get num, Getkey, Go, Gosub, Goto, Graphic, Gshape, Header, Help, Hex, If, Input, Input num, Instr, Int, Joy, Key, Left, Len, Let, List, Load, Locate, Log, Loop, Mid, Monitor, Movspr, New, Next, Not, Off, On, Open, Or, Paint, Peek, Pen, Pi, Play, Pointer, Poke, Pos, Pot, Print, Print num, Pudef, Quit, Rclr, Rdot, Read, Record, Rem, Rename, Renumber, Restore, Resume, Return, Rgr, Right, Rlum, Rnd, Rreg, Rspcolor, Rsppos, Rsprite, Rwindow, Save, Scale, Scnclr, Scratch, Sgn, Sin, Sleep, Slow, Sound, Spc, Sprcolor, Sprdef, Sprite, Sprsav, Sqr, Sshape, St, Stash, Step, Stop, Str, Swap, Sys, Tab, Tan, Tempo, Then, Ti, Ti string, To, Trap, Troff, Tron, Until, Using, Usr, Val, Verify, Vol, Wait, While, Width, Window, Xor

KeywordAbbreviationToken (hex)Version(s)Classification
RUNR{Shift+U}8A1.0 to 7.0Command and Statement

 
Syntax  
RUN lineNumber ]
 ~ or ~
RUN fileName [ , D driveNumber ] [ { , | ON } U unitNumber ] ... [ , ItwoChar ] [ , R ] ...
 
ParametersTypeLegal Value(s)Default ValueNote(s)
lineNumberUnsigned Integer0 ~ 63999first line of programIf used, must be a literal number.
fileNameString 1~16 characters  BASIC 7 only.  Non-literal must be enclosed in parentheses () 
driveNumberInteger 0 or 1 BASIC 7 only.  Non-literal must be enclosed in parentheses ()
unitNumberInteger 8 ~ 11 BASIC 7 only.  Non-literal must be enclosed in parentheses () 
twoCharChar[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 nothing.  If present, the "I" parameter must be immediately followed twoChars (any two two literal characters).   The "R" 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