RUN [line] [file$]
Executes the program in memory. If a line number is supplied then execution will begin at that line, otherwise it will start at the beginning of the program. Or, if a file name (file$) is supplied, the current program will be erased and that program will be loaded from the current drive and executed. This enables one program to load and run another.
' Run starting from root dir:
' Up a directory from where you are:
If an extension is not specified “.BAS” will be added to the file name.
The length of the path plus the file name (including punctuation) must be less than 127 characters.
Implied RUN command
At the command prompt it is possible to omit the RUN keyword and MMBasic will search the default drive and directory for a matching program and if found, it will be run.
‘program’ is the program name. If there is no extension the extension .BAS will be automatically appended.
‘command-line’ is an arbitrary string of characters which can be retrieved by the new program from the read only variable MM.CMDLINE$.
The implied RUN command is valid only at the command prompt (not within a running program).
If ‘program’ is the same as an internal MMBasic command the internal command will be run instead. To avoid this ‘program’ can be surrounded by quote marks:
"PRINT" command line
An error will be generated if the program currently in memory has been edited and not saved. If this happens (and you do not want to save the program) use the NEW command to clear the memory.
SORT INFILE.TXT OUTFILE.TXT
Will run the program SORT.BAS and the variable MM.CMDLINE$ will hold the string: “INFILE.TXT OUTFILE.TXT”
Create an MMBasic file named CMDLINE.BAS with this code:
Place it on the B: drive (SD card). With B: as the current drive, the following is a test of the command line:
> cmdline 1 2 3 4
1 2 3 4