|
BBC BASIC Command Reference
This reference to the BBC BASIC language includes command abbreviations for quicker typing of programs and the 'token' that actually represents the command in memory. A list of symbols used in the language is also given at the end of the page.
Please note: This reference is not quite complete (still to be added: extra tokens)
Command Reference
ABS
| Abbreviation:
| ABS
|
var = ABS(number)
| Token:
| &94
|
Sets var equal to the absolute value of number. Negative numbers are converted to positive.
Positive numbers are left untouched.
|
ACS
| Abbreviation:
| ACS
|
var = ACS(number)
| Token:
| &95
|
Sets var equal to the arc-cosine of number. The result is in radians (which may be converted to degrees using DEG).
|
ADVAL
| Abbreviation:
| AD.
|
Command not supported
| Token:
| &96
|
Since the NCs have no analogue port or equivalent, this command cannot be used and will result in the 'Sorry' error message.
|
AND
| Abbreviation:
| A.
|
var = number AND number
| Token:
| &80
|
Sets var equal to the logical bit-wise AND of the two numbers.
|
ASC
| Abbreviation:
| ASC
|
var = ASC(string)
| Token:
| &97
|
Sets var equal to the ASCII value of the first character of the given string.
|
ASN
| Abbreviation:
| ASN
|
var = ASN(number)
| Token:
| &98
|
Sets var equal to the arc-sine of the number. The result is in radians (which can be converted to degrees using the DEG command).
|
ATN
| Abbreviation:
| ATN
|
var = ATN(number)
| Token:
| &99
|
Sets var equal to the arc tangent of number. The result is in radians (which can be converted to degrees using the DEG command).
|
AUTO
| Abbreviation:
| AU.
|
AUTO start, step
| Token:
| &C6
|
Starts generating automatic lines numbers at line number start and goes up in increments step. If start and step aren't given it starts at 10 and goes up in steps of 10.
|
BGET
| Abbreviation:
| B.
|
var = BGET#channel
| Token:
| &9A
|
Sets var equal to the next character from the file that has been opened as channel. The file can also be the serial port "COM:".
|
BPUT
| Abbreviation:
| BP.
|
BPUT#channel, value
| Token:
| &D5
|
Writes the value to a file that has been opened as channel. The file can also be the serial port "COM:" or the parallel port "LPT:".
|
CALL
| Abbreviation:
| CA.
|
CALL address, parameters
| Token:
| &D6
|
Calls a machine code subroutine. THIS COMMAND CAN CRASH YOUR COMPUTER IF NOT USED PROPERLY.
|
CHAIN
| Abbreviation:
| CH.
|
CHAIN "program name"
| Token:
| &D7
|
Loads and runs the program stored in the file whose name is given in program name.
|
CHR$
| Abbreviation:
| CHR.
|
var = CHR$(number)
| Token:
| &BD
|
Sets the string variable var equal to the character whose ASCII code number is number.
|
CLEAR
| Abbreviation:
| CL.
|
CLEAR
| Token:
| &D8
|
This resets all dynamic variables to the unused state. The only variables left intact are the static variables A% to Z% and @%.
|
CLG
| Abbreviation:
| CLG
|
CLG
| Token:
| &DA
|
This statement clears the current graphics window (by default the entire display) to the unlit 'white' state. The graphics cursor is not moved.
|
CLOSE
| Abbreviation:
| CLO.
|
CLOSE#channel
| Token:
| &D9
|
Closes the file identified by the number channel.
|
CLS
| Abbreviation:
| CLS
|
CLS
| Token:
| &DB
|
This statement clears the current text window (by default the entire display) to 'space' characters and moves the text cursor to the top left of the window.
|
COLOUR
COLOR
| Abbreviation:
| C.
|
Command not supported
| Token:
| &FB
|
The LCD screens on the NCs cannot display colours. Use of this command will result in the 'Sorry' error message. Limited control over text attributes can be obtained with VDU.
|
COS
| Abbreviation:
| COS
|
var = COS(number)
| Token:
| &9B
|
Sets var equal to the cosine of number which is specified in radians.
|
COUNT
| Abbreviation:
| COU.
|
var = COUNT
| Token:
| &9C
|
Sets var equal to the number of characters sent to the display since the last new line.
|
DATA
| Abbreviation:
| D.
|
DATA constant, constant, constant, ...
| Token:
| &DC
|
Used to include constant data within a program which may be used by means of the READ command which will read it into variables.
|
DEF
| Abbreviation:
| DEF
|
DEF PROCname
DEF FNname
| Token:
| &DD
|
Used to begin the definition of a named procedure or function. The following example may give a taste of how this works:
10 PROCtest("Hello World")
20 PRINT FN_Average(3,9,14)
30 END
40 :
50 DEF PROCtest(string$)
60 PRINT string$
70 ENDPROC
80 :
90 DEF FN_Average(n1,n2,n3)
100 =(n1+n2+n3)/3
|
DEG
| Abbreviation:
| DEG
|
var = DEG(number)
| Token:
| &9D
|
Sets var equal to the number converted from radians to degrees. In radians a complete circle is 2*PI while in degrees a complete circle is 360 degrees, so DEG just divides by PI and multiplies by 360 (which is the same as dividing by PI and multiplying by 180).
|
DELETE
| Abbreviation:
| DEL.
|
DELETE start, finish
| Token:
| &C7
|
Deletes a range of lines from a program. DELETE 10,100 would remove all lines between 10 and 100 inclusive. To delete a single line it is easier just to type the line number on its own and press ENTER.
|
DIM
| Abbreviation:
| DIM
|
DIM var(size)
DIM var size
| Token:
| &DE
|
Reserves space for an array of items. BBC BASIC uses zero-based indexing, so, for example, DIM A(5) would reserve space for 6 items; A(0), A(1) A(2), A(3), A(4), A(5). To assign a value to this array you would use A(1) = 10
Arrays can be multi-dimensional, e.g. DIM A(5,5)
Using DIM without the dimension in brackets reserves size bytes and places the address of the first byte in var. For example DIM A 5 reserves 6 bytes. Values from 0 to 255 can then be directly placed into this reserved space using ?A = 10, ?A+1 = 25, A+2 = 31 etc.
|
DIV
| Abbreviation:
| DIV
|
var = number DIV number
| Token:
| &81
|
Sets var equal to the whole part of the result after dividing the first number by the second. The remainder is discarded. The function MOD can be used to get the remainder.
|
DRAW
| Abbreviation:
| DR.
|
DRAW x,y
| Token:
| &DF
|
Draws a straight line (in 'black' pixels) between the current position of the graphics cursor and the specified co-ordinates, then moves the graphics cursor to the specified position. The range of co-ordinates corresponding to positions on the screen is 0 to 479 in the x direction and 0 to 127 (0 to 63 for the NC100 and NC150) in the y direction. Co-ordinates may also specify points off the screen. This statement is identical to PLOT5,x,y.
|
EDIT
| Abbreviation:
| E.
|
EDIT number
This command is not available on the BBC Micro
| Token:
| &??
|
A single-line editor is provided, which is entered using the command EDIT number where number is the line number. The contents of two or more lines can be concatenated using the syntax EDIT number, number but the intermediate line numbers must be edited out, and the original lines deleted manually. A line may be duplicated by editing only the line number. The length of a line cannot be more than 255 tokens/characters in length. If you need to squeeze more onto a line, try using command abbreviations.
|
ELSE
| Abbreviation:
| EL.
|
IF condition THEN ... ELSE ...
| Token:
| &8B
|
Used to provide an alternative sequence of commands if the condition in an IF statement fails.
|
END
| Abbreviation:
| END
|
END
| Token:
| &E0
|
Marks the point where you would like the program to stop running and return to the BASIC prompt (>). END is not necessary at the highest line number since the program will stop there anyway.
|
ENDPROC
| Abbreviation:
| END.
|
ENDPROC
| Token:
| &E1
|
Marks the end of a procedure defined by DEF PROC.
|
ENVELOPE
| Abbreviation:
| ENV.
|
Command not supported
| Token:
| &E2
|
This feature is not supported on the NCs. Use of the ENVELOPE statement will result in the 'Sorry' error message.
|
EOF
| Abbreviation:
| EOF
|
var = EOF#channel
| Token:
| &C5
|
This function returns TRUE if the file pointer is at the end-of-file identified by channel. In the special case of the serial port (COM:), TRUE indicates that there are no characters waiting in the input buffer while false indicates that one or more characters waiting to be input.
|
EOR
| Abbreviation:
| EOR
|
var = number EOF number
| Token:
| &E3
|
Sets var equal to the logical bitwise exclusive OR of the two numbers.
|
ERL
| Abbreviation:
| ERL
|
var = ERL
| Token:
| &9E
|
Sets var equal to the number of the last line that caused an error.
|
ERROR
| Abbreviation:
| ERR.
|
ON ERROR GOTO line
ON ERROR OFF
| Token:
| &85
|
Used to trap errors. When an ON ERROR GOTO command is used, subsequent errors cause program control to go to the line identified in the GOTO part of the command. ERR and ERL can then be inspected to see what caused the error and if it can be corrected.
|
EVAL
| Abbreviation:
| EV.
|
var = EVAL(BASIC Expression in string)
| Token:
| &A0
|
This very powerful command passes the string to the BASIC expression handler and then sets var equal to the result. A simple 4 line program will turn BASIC into a scientific calculator:
10 REPEAT
20 INPUT "Enter commands: " e$
30 PRINT EVAL e$
40 UNTIL FALSE
|
EXP
| Abbreviation:
| EXP
|
var = EXP(number)
| Token:
| &A1
|
Sets var to the natural logarithm base (e=2.71828183) raised to the power of number. The inverse of this function is provided by LN.
|
EXT
| Abbreviation:
| EXT
|
var = EXT#channel
| Token:
| &A2
|
This function returns the size, in bytes, of an opened file. In the special case of the serial and parallel ports (COM: and LPT:) a non-zero returned value indicates that the output port is busy and if written to may result in a "Device fault". A returned value of zero indicates that the output port is ready to receive more characters.
|
FALSE
| Abbreviation:
| FA.
|
var = FALSE
| Token:
| &A3
|
FALSE is a constant defined as 0. As BASIC uses the value 0 to mean FALSE in conditional tests such as IF and UNTIL, you can use FALSE in these situations. for example, the following program will repeat forever (until STOP is pressed):
10 REPEAT
20 PRINT "Hello"
30 UNTIL FALSE
(Similar to everyone's first program: 10 PRINT "Hello World!" : GOTO 10 !)
|
FN
| Abbreviation:
| FN
|
var = FNname
DEF FNname
| Token:
| &A4
|
Used in both defining and using a named function. See DEF for more details.
|
FOR
| Abbreviation:
| F.
|
FOR var = start number TO finish number STEP step number
| Token:
| &E3
|
Used to start a repetitive loop for a fixed number of iterations. var will start at the value start number and then, each time a corresponding NEXT instruction is executed var will be increased by step number (or just one of there is no step number) until it reaches (or exceeds) finish number.
|
GCOL
| Abbreviation:
| GC.
|
Command not supported
| Token:
| &E6
|
The LCD screens on the NCs cannot display colours. Use of this command will result in the 'Sorry' error message. Limited control over text attributes can be obtained with VDU.
|
GET
| Abbreviation:
| GET
|
var = GET
| Token:
| &A5
|
Sets var equal to the ASCII value of the next key pressed. Waits for a key to be pressed before returning.
|
GET$
| Abbreviation:
| GE.
|
var$ = GET$
| Token:
| &BE
|
Sets the string variable var equal to the next character key pressed. Waits for a key to be pressed before returning.
|
GOSUB
| Abbreviation:
| GOS.
|
GOSUB line
| Token:
| &E4
|
A jump is made to the section of program starting at line. When the next RETURN command is executed control returns to the statement after the GOSUB command.
|
GOTO
| Abbreviation:
| G.
|
GOTO line
| Token:
| &E5
|
Control is transferred to the line identified in the GOTO command. To make programs easy to read the use of excessive GOTO commands should be avoided. It is better to change the flow of a program using the FOR...NEXT, REPEAT...UNTIL, DEF PROC and GOSUB structures.
|
HIMEM
| Abbreviation:
| H.
|
var = HIMEM
HIMEM = number
| Left Token:
Right Token:
| &D3
&93
|
Can be used either to set a new high address for the top of BASIC's program memory or to find our what it is currently set to. It is unwise to change this unless you know what you are doing, but it is OK to reduce it. THIS COMMAND CAN CRASH YOUR COMPUTER IF NOT USED PROPERLY.
|
IF
| Abbreviation:
| IF
|
IF condition THEN ... ELSE ...
| Token:
| &E7
|
Used to conditional execute statements. The condition is tested and if it results in a TRUE (-1) value the statements after THEN are executed. If the condition results in a FALSE (0) value then the statements after the ELSE (if present) are executed. THEN is normally optional depending on the commands which follow the condition.
IF can also be used to find a keyword in a program. For example, the following will result in all lines with the word 'Tim' being listed:
LIST IF Tim
|
INKEY
| Abbreviation:
| INKEY
|
var = INKEY(time)
| Token:
| &A6
|
Sets var equal to the ASCII value of the next key pressed. Unlike GET it only waits for the length of time given by time in 1/100ths of a second. If no key is pressed it returns -1. Use of INKEY with a negative argument to test the state of each key is not supported (because only one key can be physically registered at a time).
|
INKEY$
| Abbreviation:
| INK.
|
var$ = INKEY$(time)
| Token:
| &BF
|
Waits for time in 1/100ths of a second for a key to be pressed and returns the character in var$. If no key is pressed in time it sets var$ to the null (empty) string.
|
INPUT
| Abbreviation:
| I.
|
INPUT "prompt text", var
INPUT "prompt text", var$
| Token:
| &E8
|
Stops and displays the prompt text and then sets var equal to the user's response. var can also be a string variable to allow the user to enter text as well as numbers.
|
INPUT LINE
| Abbreviation:
| I. LIN.
|
INPUT LINE var$
| Token:
| &86
|
Allows the user to type a string of text including commas, quotes and leading spaces and assigns this to var$.
|
INPUT#
| Abbreviation:
| I.#
|
INPUT#channel,var
| Token:
| &E8
|
Inputs variable var from the file identified by channel.
|
INSTR
| Abbreviation:
| INS.
|
var = INSTR(string, string to find, number)
| Token:
| &A7
|
The first named string is searched to see if it contains the string to find and if so var is set to the position in the string where it occurs. The search can be started part way into the string by giving a number.
|
INT
| Abbreviation:
| INT
|
var = INT(number)
| Token:
| &A8
|
Converts a real number to a lower integer.
|
LEFT$
| Abbreviation:
| LE.
|
var$ = LEFT$(string$, number)
| Token:
| &C0
|
Takes the number of leftmost characters from string and assigns them to var$.
|
LEN
| Abbreviation:
| LEN
|
var$ = LEN(string$)
| Token:
| &A9
|
Sets var equal to the number of characters in the given string.
|
LET
| Abbreviation:
| LET
|
LET var = value
| Token:
| &E9
|
LET assigns a value to a variable var (either number or string). It is optional, so LET A = 10 is the same as A = 10.
|
LIST
| Abbreviation:
| L.
|
LIST number, number
| Token:
| &C9
|
Lists a program. If a single number is given then only that line is shown. If both numbers are given then all lines between and including the two are shown. While a program is listing you can press STOP to pause the display. Press it again to stop the listing.
|
LISTO
| Abbreviation:
| LISTO
|
LISTO number
| Token:
| &??
|
LISTO is used before the LIST command to control how the subsequent listing is formatted. The number affects how the listing is formatted. Valid numbers are 0 to 7. LISTO 7 gives the easiest to follow listing with indented loops and a space after the line number.
|
LN
| Abbreviation:
| LN
|
var$ = LN(number)
| Token:
| &AA
|
Sets var equal to the natural logarithm of the number. Natural logs are to the base e (=2.71828183). The inverse of LN is EXP.
|
LOAD
| Abbreviation:
| LO.
|
LOAD "program name"
| Token:
| &C8
|
Loads a program into memory and removes the program that was previously in memory. There is no prompt to save the previous program. program name is the filename of the program that you wish to load.
|
LOCAL
| Abbreviation:
| LOC.
|
LOCAL var
| Token:
| &EA
|
Specifies a variable that is only available within a procedure or function. The contents of the variables are lost (undefined) outside the function/procedure.
|
LOG
| Abbreviation:
| LOG
|
var$ = LOG(number)
| Token:
| &AB
|
Sets var equal to the base 10 logarithm of number. There is no inverse function of LOG as such because the equivalent is to use 10^number.
|
LOMEM
| Abbreviation:
| LOM.
|
var = HIMEM
HIMEM = number
| Left Token:
Right Token:
| &D2
&92
|
May be used to read and set the point in memory where dynamic data structures will be placed. THIS COMMAND CAN CRASH YOUR COMPUTER IF NOT USED PROPERLY.
|
MID$
| Abbreviation:
| M.
|
var$ = MID$(string$ , start , length)
| Token:
| &C1
|
Sets var$ equal to a string of characters taken from string$ starting at position start for length characters.
|
MOD
| Abbreviation:
| MOD
|
var$ = number MOD number
| Token:
| &83
|
Divides the first number by the second and sets var equal to the remainder. See also DIV which sets var equal to the whole part of the result.
|
MODE
| Abbreviation:
| MO.
|
Command not supported
| Token:
| &EB
|
The NCs have only one screen mode/resolution. Use of this command will result in the 'Sorry' error message.
|
MOVE
| Abbreviation:
| MOV.
|
MOVE x , y
| Token:
| &EC
|
Moves the graphics cursor to the specified co-ordinates, but does not affect what is displayed. This statement is identical to PLOT 4, x , y.
|
NEW
| Abbreviation:
| NEW
|
NEW
| Token:
| &CA
|
Clears the current program from memory. If you use this accidentally you can immediately use OLD to recover it but OLD will no longer function once you start to enter new program lines or set variables.
|
NEXT
| Abbreviation:
| N.
|
NEXT var
| Token:
| &ED
|
Used to mark the end or a FOR loop and cause a jump back to the statement after the FOR until the loop variable var has reached its upper limit. The var name is optional but can be added for readability.
|
NOT
| Abbreviation:
| NOT
|
var = NOT number
| Token:
| &AC
|
Sets var equal to the bit by bit binary inversion of number.
|
OFF
| Abbreviation:
| OFF
|
ON ERROR OFF
TRACE OFF
| Token:
| &87
|
Used to turn a feature off.
|
OLD
| Abbreviation:
| O.
|
OLD
| Token:
| &CB
|
Used to recover a program immediately after the accidental use of NEW.
|
ON
| Abbreviation:
| ON
|
ON var GOTO line , line ... ELSE command
ON var GOSUB line , line ... ELSE command
ON var PROCone , PROCtwo ... ELSE command
ON ERROR ...
| Token:
| &EE
|
Can be used to GOTO or GOSUB a number of different lines depending on the value of var. Can also be used to call different named procedures dependent on the value of var.
|
OPENIN
| Abbreviation:
| OP.
|
channel = OPENIN(string)
| Token:
| &8E
|
The file whose name is given by string is opened for input (reading) and a file number is assigned to channel. This variable should be used in subsequent file handling commands such as BGET#, INPUT# and CLOSE#. If the filename given is 'COM:' then input will be taken from the serial port. A maximum of seven files can be opened at any one time.
|
OPENOUT
| Abbreviation:
| OPENO.
|
channel = OPENOUT(string)
| Token:
| &AE
|
The file whose name is given by string is opened for output (writing) and a file number is assigned to channel. This variable should be used in subsequent file handling commands such as BPUT#, OUTPUT# and CLOSE#. If the filename given is 'COM:' then output will be go to the serial port. If the filename given is 'LPT:' then output will be go to the parallel port. A maximum of seven files can be opened at any one time.
|
OPENUP
| Abbreviation:
| OPENU.
|
channel = OPENUP(string)
| Token:
| &AD
|
The file whose name is given by string is opened for input and output and a file number is assigned to channel. This variable should be used in subsequent file handling commands. If the filename given is 'COM:' then output will be go to the serial port. A maximum of seven files can be opened at any one time.
|
OR
| Abbreviation:
| OR
|
var = number OR number
| Token:
| &84
|
Sets var equal to the result of the logical bit-wise OR of the two numbers.
|
OSCLI
| Abbreviation:
| OSC.
|
OSCLI(string)
| Token:
| &FF
|
The string is passed to the OS to be executed. This can be one of the Star Commands such as *CAT. The * should not be included in an OSCLI command. Useful for use in IF statements where you need commands following the OS command, (eg., IF A = 10 THEN OSCLI("CAT"):GOTO 10) since * commands do not allow execution to continue on the same line.
|
PAGE
| Abbreviation:
| PA.
|
PAGE = var
var = PAGE
| Left Token:
Right Token:
| &D0
&90
|
PAGE can be used to read or set the starting address of the current program area. THIS COMMAND CAN CRASH YOUR COMPUTER IF NOT USED PROPERLY.
|
PI
| Abbreviation:
| PI
|
var = PI
| Token:
| &AF
|
Sets var to the value of p (=3.14159265), the ratio of a circle's circumference to its diameter.
|
PLOT
| Abbreviation:
| PL.
|
PLOT n , x , y
| Token:
| &F0
|
A multi-purpose plotting command, whose effect is controlled by the number n. For a list of options see the Plot Commands Data Sheet.
|
POINT
| Abbreviation:
| PO.
|
var = POINT(x , y)
| Token:
| &B0
|
This function sets var to the state of the pixel at the specified location, as 0 (white) or 1 (black). If the specified point is outside the graphics window (taking into account the position of the graphics origin) the value -1 is returned.
|
POS
| Abbreviation:
| POS
|
var = POS
| Token:
| &B1
|
This function sets var equal to the horizontal position (column) of the text cursor with respect to the left-hand edge of the current text window, in the range 0 to 79.
|
PRINT
| Abbreviation:
| P.
|
PRINT var or text or number
| Token:
| &F1
|
Prints the contents of a variable or variables and fixed text on the screen. See the symbols reference at the end of the page for details of symbols that can be used with PRINT to affect the output.
|
PROC
| Abbreviation:
| PRO.
|
DEF PROCname
PROCname
| Token:
| &F2
|
Used in both defining and using a named procedure. See DEF for more details.
|
PTR
| Abbreviation:
| PT.
|
var = PTR#channel
PTR#channel = var
| Left Token:
Right Token:
| &CF
&8F
|
Allows the random access pointer of file channel to be read or set.
|
PUT
| Abbreviation:
| PUT
|
PUT port , var
| Token:
| &??
|
Outputs a value to an I/O port address. THIS COMMAND CAN CRASH YOUR COMPUTER IF NOT USED PROPERLY.
|
RAD
| Abbreviation:
| RAD
|
var = RAD(number)
| Token:
| &B2
|
Sets var equal to the value of number converted from degrees to radians.
|
READ
| Abbreviation:
| REA.
|
READ var
| Token:
| &F3
|
Reads data from a DATA statement and assigns it to var.
|
REM
| Abbreviation:
| REM
|
REM comment
| Token:
| &F4
|
Allows comments to be added to programs. Anything following REM is considered a remark and will be ignored by BASIC. It is good practice to include comments in programs so that at a later date you will understand what a particularly complicated line really does! It can also be used to temporarily disable a command during testing.
|
RENUMBER
| Abbreviation:
| REN.
|
RENUMBER start , step
| Token:
| &CC
|
Renumbers a program starting at line 10 and going up in steps of 10. If start and step are given then numbering will begin at start and go up in units of step.
|
REPEAT
| Abbreviation:
| REP.
|
REPEAT
| Token:
| &F5
|
Used to begin a loop that ends with the command UNTIL.
|
REPORT
| Abbreviation:
| REPO.
|
REPORT
| Token:
| &F6
|
This prints the error message associated with the last error that occurred and is usually used in an ON ERROR GOTO trap to print an error message when the program determines that the error which has occurred is not one that it can cope with.
|
RESTORE
| Abbreviation:
| RES.
|
RESTORE line
| Token:
| &F7
|
When using READ to read data from DATA statements, RESTORE can be used to set the reading pointer back to a specified line so that data can be re-read.
|
RETURN
| Abbreviation:
| R.
|
RETURN
| Token:
| &F8
|
Used at the end of a section of program that has been jumped to by the GOSUB command. Control returns to the statement after the GOSUB.
|
RIGHT$
| Abbreviation:
| RI.
|
var = RIGHT$(string$, number)
| Token:
| &C2
|
Sets var$ equal to the string of characters taken from the rightmost end of string$ and of length number.
|
RND
| Abbreviation:
| RND
|
var = RND(number)
| Token:
| &B3
|
Sets var equal to a random number between 1 and number.
If number is not given then the random number is between -2147483648 and +2147483647.
If number is negative then the random generator is set to a value based on that number and that number is returned in var.
If the number is 0 then the result of a previous RND is returned.
If the number is 1 then a random number between >= 0 and <1 is returned.
|
RUN
| Abbreviation:
| RUN
|
RUN
| Token:
| &F9
|
Starts running the program currently held in memory.
|
SAVE
| Abbreviation:
| SA.
|
SAVE "program name"
| Token:
| &CD
|
The current program in memory is saved to the program name file. Programs are not automatically saved when you leave BASIC, so you must use the SAVE command.
|
SGN
| Abbreviation:
| SGN
|
var = SGN(number)
| Token:
| &B4
|
Sets var equal to the Sine of the given angle which must be specified in radians. The RAD function can be used to change an angle in degrees into radians before using the SIN function.
|
SOUND
| Abbreviation:
| SO.
|
SOUND channel, volume, pitch, duration
| Token:
| &D4
|
SOUND will make a sound on the NCs speaker. There are two sound channels, 1 and 2. The volume is not variable (as it is on the BBC Micro) so it can be left at 0. The pitch indicates the note to be played -- middle C is a value of 100. Although a change of 1 in the pitch value should alter the pitch by a quarter semitone (as on the BBC Micro), the NCs can only play notes in steps of a semitone. The duration of the note is given in 1/100ths of a second. The values -1 or 255 cause infinite sound, which can be stopped only by issuing another SOUND command or by pressing STOP.
|
SPC
| Abbreviation:
| SPC
|
PRINT SPC(number)
| Token:
| &89
|
When used in either a PRINT or INPUT command SPC prints number spaces before any following text.
|
SQR
| Abbreviation:
| SQR
|
var = SQR(number)
| Token:
| &B6
|
Sets var equal to the square root of number.
|
STEP
| Abbreviation:
| S.
|
FOR var = start TO finish STEP step
| Token:
| &88
|
Allows a FOR...NEXT variable to be increased or decreased in steps other than one.
|
STOP
| Abbreviation:
| STO.
|
STOP
| Token:
| &FA
|
Just like END, STOP stops the program running but prints a message to say where the program stopped. Liberal use of STOP commands can help to trace the flow of execution.
|
STR$
| Abbreviation:
| STR.
|
var$ = STR$(number)
| Token:
| &C3
|
Sets var$ to be equal to a number in the same format that it would be printed in.
|
STRING$
| Abbreviation:
| STRI.
|
var$ = STRING$(number,string)
| Token:
| &C4
|
Sets var$ equal to number of repetitions of string.
|
TAB
| Abbreviation:
| TAB
|
PRINT TAB(x, y)
| Token:
| &8A
|
Used to arrange for the printed output of a PRINT or INPUT command to appear on the screen at location x, y with respect to the current text window.
|
TAN
| Abbreviation:
| T.
|
var = TAN(number)
| Token:
| &B7
|
Sets var equal to the tangent of the angle number. This must be specified in radians. Use the RAD function to convert the number from degrees to radians.
|
THEN
| Abbreviation:
| TH.
|
IF condition THEN ... ELSE ...
| Token:
| &8C
|
Introduces the statements in an IF command that should be executed if the condition is met. The use of THEN is optional, except when using GOTO where, for example, either IF A = 10 THEN GOTO 430 or IF A = 10 THEN 430 or IF a = 10 GOTO 430 could be used.
|
TIME
| Abbreviation:
| TI.
|
TIME = var
var = TIME
| Left Token:
Right Token:
| &D1
&91
|
A variable that can be set or read to measure elapsed time. It increments once every 1/100ths of a second. A typical use is for a delay, in this case 1 second:
10 TIME = 0
20 REPEAT
30 UNTIL TIME > 1000
|
TIME$
| Abbreviation:
| TIME$
|
TIME$ = var$
var$ = TIME$
| Token:
| &??
|
Sets var$ equal to a string which contains the current date and time in a fixed format. MID$ can be used to pick the selected fields from this variable. TIME$ can also be set, in which case the Day of Week text can be ignored and need not be set. See the BBC BASIC Information Page for details of the TIME$ format.
|
TO
| Abbreviation:
| TO
|
FOR var = start TO finish STEP step
| Token:
| &B8
|
Used in a FOR statement to divide the starting value from the end value of the loop variable.
|
TOP
| Abbreviation:
| TOP
|
var = TOP
TOP = number
| Token:
| &??
|
TOP gives you the address of the first free memory location after the top of the BASIC program. TOP-PAGE will give the length of your BASIC program in bytes. TOP usually has the same value as LOMEM. THIS COMMAND CAN CRASH YOUR COMPUTER IF NOT USED PROPERLY.
|
TRACE
| Abbreviation:
| TR.
|
TRACE ON
TRACE OFF
TRACE number
| Token:
| &FC
|
The command TRACE ON will cause BASIC to print the number of each line it executes in square brackets to allow the flow of the program to be followed. Tracing can be turned off using TRACE OFF. If the command TRACE number is used then only line numbers below number will be printed. By placing all subroutines at high numbered lines and the main program in the low numbered lines you can arrange to only show tracing of the main part of the program.
|
TRUE
| Abbreviation:
| TRUE
|
var = TRUE
| Token:
| &B9
|
Sets var to be equal to the value -1 that BASIC understands as TRUE in IF and UNTIL commands.
|
UNTIL
| Abbreviation:
| U.
|
UNTIL condition
| Token:
| &FD
|
Ends a loop started by the REPEAT command. As long as the condition is not met, a jump will be made back to the statement after REPEAT.
|
USR
| Abbreviation:
| USR
|
var = USR(number)
| Token:
| &BA
|
Calls a machine code routine at address number and returns the value of the HL and HL' registers to the named variable. THIS COMMAND CAN CRASH YOUR COMPUTER IF NOT USED PROPERLY.
|
VAL
| Abbreviation:
| VAL
|
var = VAL(string)
| Token:
| &BB
|
Converts as much of a string that can be interpreted as a number into a numeric value and assigns it to var.
|
VDU
| Abbreviation:
| V.
|
VDU number , number ...
| Token:
| &EF
|
Passes the elements of the list to the VDU emulator. Items terminated by a semi-colon are sent as a 16-bit number, LSB first. All console output is passed to a software emulator of the BBC Micro's VDU drivers. VDU codes perform a function similar to those of the BBC Micro, consistent with the hardware and OS differences. For a list of VDU command codes see the VDU Commands Data Sheet.
|
VPOS
| Abbreviation:
| VP.
|
var = VPOS
| Token:
| &BC
|
Sets var to the vertical position (row) of the text cursor with respect to the top of the current text window, in the range 0 to 7 for the NC100 and NC150, or 0 to 15 for the NC200.
|
WIDTH
| Abbreviation:
| W.
|
WIDTH number
| Token:
| &FE
|
Sets the width of print zones. A value of zero will stop it taking any action.
|
Operating System Command Reference
*BYE
*QUIT
|
|
|
|
|
|
Exits from BBC BASIC and returns control to the Operating System.
|
*CAT
*DIR
*.
|
|
|
|
|
|
Lists a catalogue of all stored files.
|
*DELETE
*ERASE
|
|
|
*DELETE "file"
|
|
|
Deletes the specified file.
|
*ESC
|
|
|
*ESC ON
*ESC OFF
|
|
|
Enables or disables the abort action of the STOP key which is known in BASIC as the ESCAPE key. After *ESC OFF the ESCAPE key simple returns the ASCII code ESC (27). *ESC ON restores the normal action of the ESCAPE key.
|
*EXEC
|
|
|
*EXEC filename
|
|
|
Accepts console input from the specified file instead of from the keyboard (note that GET and INKEY always read from the keyboard.)
|
*KEY
|
|
|
*KEY number "string"
|
|
|
Redefines a key to return the specified string. The key number is from 0 to 127, where 41 to 66 correspond to SYMBOL+A to SYMBOL+Z. The string may contain the ESC character | in order to insert non-printing characters. For example, |M indicates ENTER, |? indicates DELETE, || indicates the character | itself and |! causes bit 7 of the following character to be set. If the string is enclosed in quotes (which is optional), |" allows the " character to be included.
|
*LOAD
|
|
|
*LOAD filename aaaa
|
|
|
Loads the specified file into memory at hex address aaaa. The load address must be specified and point to a valid memory location.
|
*PRINTER
|
|
|
*PRINTER number
|
|
|
Selects the printer as parallel (number=0) or serial (number=1).
|
*RENAME
|
|
|
*RENAME oldfile newfile
|
|
|
Renames the oldfile as newfile.
|
*SAVE
|
|
|
*SAVE filename aaaa bbbb
*SAVE filename aaaa +llll
|
|
|
Saves a specified range of memory to a file. The address range is specified either as start address aaaa and end address bbbb or end address length llll.
|
*SPOOL
|
|
|
*SPOOL file
*SPOOL
|
|
|
Copy all subsequent console output to the specified file. If the filename is omitted, any current spool file is closed and spooling is terminated.
|
*|
|
|
|
*| comment
|
|
|
This is a comment line. Anything following the | is ignored.
|
Symbols and Mathematical Operators Reference
|
|
|
A = 10
FOR A = 1 TO 10
IF A = 10 THEN ...
|
|
|
The equal sign is used to make assignments to variables or in conditional tests.
|
|
|
|
PRINT "hello"
|
|
|
Double Quotes are used to enclose a string of characters.
|
|
|
|
PRINT 100 ' 200 ' 300
|
|
|
A Single Quote is used in a PRINT statement to move the text cursor down one line.
|
|
|
|
PRINT 100 , 200 , 300
DIM A(10,10,10)
DATA Tim, Allan, John
|
|
|
A Comma is used in a PRINT statement to move the text cursor to the next tab stop (tabs are every ten characters), or to separate command parameters.
|
|
|
|
PRINT 100 ; 200 ; 300
VDU 29,300;10;
|
|
|
A Semi-colon is used in a PRINT statement to ensure that subsequent text will be placed immediately after the previous text, rather than on a new line. It is also used in VDU commands where values greater than 255 are being passed.
|
|
|
|
A = 10 : INPUT B : PRINT A , B
IF A = 2 THEN PRINT "A equals 2" : GOTO 220
|
|
|
A Colon is used to separate statements that you want to put on the same line. This is especially useful in IF statements.
To place commands that have a fixed number of arguments on the same line, the colon can be replaced with a space, eg., REPEAT UNTIL FALSE
|
|
|
|
A$ = "hello"
|
|
|
A Dollar Sign placed after a variable name indicates that the variable is a string that can hold characters rather than a number. The same sign is also part of some commands such as CHR$.
A dollar sign followed by a memory location in hexadecimal will allow a string to be stored from that memory location. So $&4000 = "Hello" will store the ASCII codes for each letter of 'Hello' starting at memory location &4000. A carriage return character (13) will also be added to the end of the string. A similar technique will retrieve the string: A$ = $&4000
|
|
|
|
A% = 100
|
|
|
A Percentage Sign placed after a variable name indicates that the variable is a 32-bit integer variable that can only hold whole numbers. These variables use less memory than normal variables. Some are special to the Z80 assembler, such as A% being the Accumulator. @% is a special variable that determines how numbers and strings are displayed:
@% = &aabbccdd
where:
aa = Strings formatted? 0 = no 1 = yes
bb = Format type: 0 = general 1 = exponential 2 = fixed field
cc = Digit control: general field or mantissa or decimal places
dd = Field width
|
|
|
|
A = &A7
|
|
|
An Ampersand placed before a number tell BASIC that the number is specified in hexadecimal notation.
|
|
|
|
INPUT#K , num
|
|
|
A Hash tells BASIC that the contents of the following variable is a channel number for a file.
|
|
|
|
PRINT ~A
|
|
|
A Tilde is used in a PRINT statement to ensure that the contents of a numerical variable will be displayed in hexadecimal notation.
|
|
|
|
A = B*C
*QUIT
|
|
|
An Asterisk is used for mathematical multiply. It also precedes Star Commands such as *QUIT which are handled by the OS. Note that any commands placed after a Star Command will not execute.
|
|
|
|
A = B/C
|
|
|
A Slash is used for mathematical divide.
|
|
|
|
A = B+C
|
|
|
A Plus is used for mathematical addition.
|
|
|
|
A = B-C
|
|
|
A Minus is used for mathematical subtraction.
|
|
|
|
A = B^C
|
|
|
Used for mathematical to-the-power-of.
|
|
|
|
IF A < B THEN ...
|
|
|
A Smaller Than symbol is use to compare two numbers or characters and take the logical lowest (using ASCII code in the case of characters).
|
|
|
|
IF A > B THEN ...
|
|
|
A Greater Than symbol is use to compare two numbers or characters and take the logical highest (using ASCII code in the case of characters).
|
|
|
|
?1000 = 20
PRINT ?1000
|
|
|
A Question Mark allows the contents of a memory location to be set and read.
|
|
|
|
A$ = LEFT$(B$,4)
A = (B+C)*D
IF (A = 1 AND B=5) OR (A = 2 AND B = 4) THEN ...
|
|
|
Brackets are used to enclose command parameters, in mathematical expressions to indicate order of calculation, and in logical tests in IF and UNTIL statements.
|
|
|
|
|
|
|
Square Brackets are used to enclose machine code routines.
|
Have you written an interesting program for your NC, or done something interesting with it (such as interfacing it to the outside world)?
If so, please email me at and get your article on this website!
|