Chapter 12 : Commands
BBC BASIC, like many interpreters, has always included a number of commands within its syntax, such as RUN and SAVE. Such commands are indistinguishable from basic instructions, being written solely in upper case. The difference is more one of user perception. Generally speaking, such commands apply to the program as a whole, such as the two examples given, or in some way control or change the environment containing the program. EDIT, for example, completely changes the context of a program. In practice, many of these so-called commands may also be included as part of a program. run, mistakenly in my view, is quite often included in this way.
BASIC V provides a number of additional commands compared with previous versions of BBC BASIC, and a number of others have been changed or extended in their function. These commands are as follows.
|APPEND||This command may be used to append any saved file to another program already in memory. The file name may be given explicitly as a string in quotes, for example, append "Functions", or contained in a specified string variable such as append ProgS. If the specified file contains a basic program in tokenised format, then the line numbers and any references to them in the appended program will be renumbered to follow the last line of the program already in memory. This is much better than the previous use of "SPOOL and *exec to achieve the same result, though these two commands may still have a part to play on occasion.|
|EDIT||In BASIC V, the edit command calls the arm basic Editor with the current program loaded, ready for editing. Shift-f4 returns from the editor back to basic. The editor is described in the User Guide and provides an easy-to-use facility for basic programmers.|
|HELP||This command by itself gives information about the current basic program, such as size in bytes. The command 'HELP' displays all basic keywords, while HELP followed by an initial letter gives all keywords beginning with that letter. HELP followed by an individual keyword gives a description of that keyword.|
|LVAR||When developing or debugging a program this command can be useful, as it displays the current state of all the inbuilt integer variables and all other variables used in your program. It also lists the procedures and functions called by the program, indicating the type of each parameter, real, integer or string, and the first lines of any loaded procedure and function libraries (see Chapter Five). It also lists arrays together with their dimensioned size. The limitation in the use of lvar which, in some circumstances, could be to your advantage, is that only those variables, procedures and functions referenced prior to the lvar call will be listed. So, for example, only those procedures and functions which have been called will appear, not necessarily all the procedures and functions defined in a program.|
|SAVE||If the first line of a program consists of a rem statement followed by '>', then the save command, without any further specification, will save the current BASIC program under the file name specified after the '>'. For example, starting a program with:
10 REM >Graph1
would result in the save command saving the program using the name Graphl. This is a most useful facility. Editing the file name as program development progresses enables different versions to be named and saved quite easily. Note that no warning is given if this use of the save command overwrites an existing file with the same name.
|LISTO||The listo command now works as follows, depending on the number following the command:|
0 no changes
bit 0 =1 a single space after the line number
bit 1 =1 indent any structures
bit 2 =1 split when':' encountered
bit 3 =1 don't list line numbers
bit 4 =1 list tokens in lower case
|TWIN||Calls the Twin text editor to edit the current basic program.|
|TWIN0||Calls the Twin text editor with a listo capability, ie. the TWIN0 command should be followed by a number as defined for LISTO.|
|TRACE||The trace command has been enhanced to trace procedures and functions, and to trace in single-step mode. Various single parameters may follow the trace command as detailed below:
will display all line numbers encountered below (that is after) the value of <expression>.
will trace all line numbers, and is thus equivalent to trace 65279, the highest possible line number.
will display the name of each procedure or function encountered.
TRACE STEP <expression>
TRACE STEP ON
TRACE STEP PROC
are similar to the first three variations on trace described above except that when a line number, or procedure or function name, has been displayed, execution of the program in question pauses until a key is pressed.
simply switches the trace facility off. The trace command can be included anywhere within a program, and is a useful aid for resolving some of the knottier problems which may occur during program development.