BBC BASIC Keywords
ABS | Absolute value (function) | |||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Returns the absolute positive value of its argument. | |||||||||||||||||||||||||||
ACS | Arc cosine (function) | |||||||||||||||||||||||||||
| Returns the arc cosine of its argument in radians. The permitted range of the argument is -1 to +1- For example,
will print 60, because COS(60°) is 0.5. | |||||||||||||||||||||||||||
AND (A.) | Logical AND (operator) | |||||||||||||||||||||||||||
| Performs a bitwise logical AND between two operands which are internally converted to 4 byte integers before the operation. It is normally used to join two conditions in an IF or UNTIL statement; thus
ensures that a rectangle is larger than 10 x 10. | |||||||||||||||||||||||||||
ASC | ASCII value (function) | |||||||||||||||||||||||||||
| Returns the ASCII character value of the first character of the argument string.
gives 90, the ASCII value of "Z". The brackets are optional, and | |||||||||||||||||||||||||||
ASN | Arc sine (function) | |||||||||||||||||||||||||||
| Returns the arc sine of its argument in radians. The permitted range of the argument is -1 to +1. | |||||||||||||||||||||||||||
ATN | Arc tangent (function) | |||||||||||||||||||||||||||
| Returns the arc tangent of its argument in radians. | |||||||||||||||||||||||||||
AUTO (AU.) | Automatic numbering (command) | |||||||||||||||||||||||||||
| Allows lines to be entered without first typing in the number of the line. The line numbers are preceded by the usual prompt (>). By default the starting line number and increment are both 10, but they may optionally be specified; for example
will start with line 20, and
will start at line 100 and increment by 20. AUTO will continue generating line numbers until you press . | |||||||||||||||||||||||||||
BGET (B.#) | Byte from data file (function) | |||||||||||||||||||||||||||
| Returns a byte from the data file whose channel number is its argument. The file pointer is incremented after the byte has been read. For example,
reads the next character from file c.
| |||||||||||||||||||||||||||
BPUT# (BP.#) | Output a byte (statement) | |||||||||||||||||||||||||||
|
Puts a byte to the data file whose channel number is the first argument. The second argument's least significant byte is written to the file. The file pointer is incremented after the byte has been written. Thus
writes char to file channel. | |||||||||||||||||||||||||||
CALL (CA.) | Call machine-code (statement) | |||||||||||||||||||||||||||
| Calls a machine code subroutine at a specified address, passing parameters in a parameter block addressed by the Z80's IX register. The IY register is set to the address of the machine code subroutine being called. The processor's A, B, C, D, E, F, H, and L registers are initialised to the least significant bytes of A%, B%, C%, D%, E%, F%, H%, and L% respectively. This statement could cause corruption of the Cambridge Z88 memory, and should therefore only be used by experienced programmers. The parameter block contains the following list:
where the parameter types are as follows:
In the case of a string variable the parameter address is the address of a String Information Block which gives the current length of the string, number of bytes allocated, and start address, in that order.
| |||||||||||||||||||||||||||
CHAIN (CH.) | Load and run program (statement) | |||||||||||||||||||||||||||
| Loads and runs the program whose name is specified in the argument allowing one program to load another. Information can be passed between programs using the static variables @%, and A% to Z%. | |||||||||||||||||||||||||||
CHR$ | ASCII character (function) | |||||||||||||||||||||||||||
| Returns the ASCII character string specified by the least significant byte of the numeric argument.
will set A$ to 70, since ASC"Z" is 90. The characters corresponding to values 32 and above can be displayed on the screen with the line
| |||||||||||||||||||||||||||
CLEAR (CL.) | Clear program (statement) | |||||||||||||||||||||||||||
| Clears all variables, including strings apart from the static variables @%, and A% to Z%. | |||||||||||||||||||||||||||
CLG | Clears Graphics Window | |||||||||||||||||||||||||||
| This clears the graphics window (only); it does not affect the position of the graphics cursor. Note: CLS can be used to clear the text window and leave the graphics window unchanged. | |||||||||||||||||||||||||||
CLOSE (CL.#) | Close channel (statement) | |||||||||||||||||||||||||||
| Closes a specified channel. For example,
closes channel c. | |||||||||||||||||||||||||||
CLS | Clear text area (statement) | |||||||||||||||||||||||||||
| Clears the text area of the screen. The text cursor is moved to the 'home' position (0,0) at the top left-hand character position of the text area. | |||||||||||||||||||||||||||
COLOUR |
| |||||||||||||||||||||||||||
| not implemented. | |||||||||||||||||||||||||||
COS | Cosine (function) | |||||||||||||||||||||||||||
| Returns the cosine of its argument in radians.
| |||||||||||||||||||||||||||
COUNT (COU.) | Character count (function) | |||||||||||||||||||||||||||
| Returns the number of characters sent to the output stream (VDU or printer) since the last new line. For example,
will pad the line with dots to 72 characters | |||||||||||||||||||||||||||
DATA (D.) | Data (statement) | |||||||||||||||||||||||||||
| Introduces lists of data for use by the READ statement (see READ). | |||||||||||||||||||||||||||
DEF | Define function/procedure (statement) | |||||||||||||||||||||||||||
| Precedes declaration of a user-defined function (FN) or procedure (PROC). DEF must be used at the start of a program line. For example,
defines a function to convert Fahrenheit to Celsius. Executing
will convert 98.4 to Celsius. | |||||||||||||||||||||||||||
DEG | Degrees (function) | |||||||||||||||||||||||||||
| Returns the argument converted from radians to degrees. For example
will print 90 | |||||||||||||||||||||||||||
DELETE (DEL.) | Delete lines (command) | |||||||||||||||||||||||||||
| Deletes a group of lines from the program. Both start and end lines of the group will be deleted. For example
will delete all lines between 123 and 456 inclusive, which need not exist. | |||||||||||||||||||||||||||
DIM | Dimension array (statement) | |||||||||||||||||||||||||||
| Dimensions an array, or reserves an area of memory for special applications. For example,
dimensions a two-dimensional string array a$ with elements a$(0,0) up to a$(10,20). Arrays may have one or more dimensions, and may be string arrays, floating-point arrays, or integer arrays.
reserves 25 bytes and puts the address of byte 0 in the variable X%. | |||||||||||||||||||||||||||
DIV | Integer divide (operator) | |||||||||||||||||||||||||||
| Gives the integer quotient of two items. The result is always an integer. X=A DIV B y=(top+bottom+1) DIV 2 | |||||||||||||||||||||||||||
DRAW x,y | Draw black straight line | |||||||||||||||||||||||||||
| Draws a straight line (in black) between the current position of the graphics cursor and the specified coordinates, then moves the graphics cursor to the specified position. This statement is identical to PLOT 5. | |||||||||||||||||||||||||||
ELSE (EL.) | Else clause (statement) | |||||||||||||||||||||||||||
| An optional part of the IF...THEN, or ON...GOSUB, ON...GOTO statements, it introduces the action to be taken if the testable condition evaluates to FALSE, or the ON expression is out of range. | |||||||||||||||||||||||||||
END | End program (statement) | |||||||||||||||||||||||||||
| Returns to direct mode. | |||||||||||||||||||||||||||
ENDPROC | End procedure (statement) | |||||||||||||||||||||||||||
| Denotes the end of a procedure defined with DEF PROC. | |||||||||||||||||||||||||||
EOF# | End of file (function) | |||||||||||||||||||||||||||
| Returns -1 (TRUE) if the end of the specified data file has been reached. For example,
will read characters until the end of the file whose channel number is the variable | |||||||||||||||||||||||||||
EOR | Logical Exclusive-OR (operator) | |||||||||||||||||||||||||||
| Performs a bitwise integer logical exclusive-or between two operands which are internally converted to 4 byte integers before the operation. | |||||||||||||||||||||||||||
ERL | Error line (function) | |||||||||||||||||||||||||||
| Returns the line number of the line where the last error occurred. For example,
| |||||||||||||||||||||||||||
ERR | Error code (function) | |||||||||||||||||||||||||||
| Returns the error code number of the last error which occurred. | |||||||||||||||||||||||||||
EVAL (EV.) | Evaluate string (function) | |||||||||||||||||||||||||||
| Returns the result of evaluating the given expression supplied as a string. For example,
| |||||||||||||||||||||||||||
EXP | Exponent (function) | |||||||||||||||||||||||||||
| Returns 'e' (2.71828183) to the power of the argument. | |||||||||||||||||||||||||||
EXT# | Extent of file (function) | |||||||||||||||||||||||||||
| Returns the total length of the file whose channel number is its argument. The file must have been opened with OPENIN, OPENUP, or OPENOUT. | |||||||||||||||||||||||||||
FALSE (FA.) | False (function) | |||||||||||||||||||||||||||
| Returns the value zero representing logical false. For example,
will continue forever. | |||||||||||||||||||||||||||
FN | Function (statement) | |||||||||||||||||||||||||||
| Introduces a user-declared function. The first character of the function name can be a letter, underline, or a number. No spaces are allowed between the function name and the opening bracket of the parameter list (if any). | |||||||||||||||||||||||||||
FOR (F.) | Start FOR loop (statement) | |||||||||||||||||||||||||||
| Initialises a FOR ... NEXT loop. The loop is executed at least once for each of the values of the control variable in the specified range. FOR card=1 TO 6 PRINT card; NEXT card will print 1 2 3 4 5 6 | |||||||||||||||||||||||||||
GCOL |
| |||||||||||||||||||||||||||
| not implemented. | |||||||||||||||||||||||||||
GET/GET$ | Wait for key (function) | |||||||||||||||||||||||||||
Waits for a key to be pressed on the keyboard. GET returns the ASCII value, and GET$ returns the corresponding single-character string. For example,
waits for to be pressed. | ||||||||||||||||||||||||||||
GOSUB (GOS.) | Call subroutine (statement) | |||||||||||||||||||||||||||
| Calls a section of a program as a subroutine at a specified line number. Control returns to the next statement when RETURN is encountered in the subroutine. One subroutine may call another subroutine (or itself). 100 GOSUB 120
110 END
120 PRINT "Hello"
130 RETURN | |||||||||||||||||||||||||||
GOTO (G.) | Go to line (statement) | |||||||||||||||||||||||||||
Transfers program control to a line with a specified or calculated line number. For example,
The use of the calculated GOTO, as in the second example, is not recommended as it will not be renumbered correctly by the RENUMBER command. | ||||||||||||||||||||||||||||
HIMEM (H.) | High memory bound (function) | |||||||||||||||||||||||||||
A pseudo-variable which contains the address of the first byte of free memory. | ||||||||||||||||||||||||||||
IF | Condition (statement) | |||||||||||||||||||||||||||
Sets up a test condition which can be used to control the subsequent flow of the program. It is part of the IF ... THEN ... ELSE structure. The word THEN is optional under most circumstances. IF length-5 THEN 110
IF A<C OR A>D GOTO 110
IF A>C AND C>-D THEN GOTO 110 ELSE PRINT "CCL" | ||||||||||||||||||||||||||||
INKEY/INKEY$ | Read key (function) | |||||||||||||||||||||||||||
Waits for up to a specified number of clock ticks (10ms each). If no key is pressed in the time limit, INKEY will return -1 and INKEY$ will return a null string; otherwise the INKEY function will return the ASCII value of the key pressed. | ||||||||||||||||||||||||||||
INPUT (I.) | Input value (statement) | |||||||||||||||||||||||||||
Inputs values from the keyboard. The INPUT statement normally prints a ? prompt for each variable in the list. Alternatively strings can be included in the list of variables to be printed as prompts; omitting the comma after a string will suppress the question mark. For example:
| ||||||||||||||||||||||||||||
INPUT LINE | (statement) | |||||||||||||||||||||||||||
| Identical to INPUT except that the entire line, including commas, quotes and leading spaces is input into a string variable.
| |||||||||||||||||||||||||||
INPUT# | Input from file (statement) | |||||||||||||||||||||||||||
Reads data from a file into specified variables. The data should have been written to the file with a corresponding PRINT# statement. | ||||||||||||||||||||||||||||
INSTR | Substring (function) | |||||||||||||||||||||||||||
Returns the position of a substring within a string, optionally starting the search at a specified place in the string. The leftmost character position is 1. If the sub-string is not found, 0 is returned. For example,
will print 12, and
will start the search at character 5 and print 7. | ||||||||||||||||||||||||||||
INT | Integer (function) | |||||||||||||||||||||||||||
Converts a real number to the next lower or equal integer.
| ||||||||||||||||||||||||||||
LEFT$ | Left of string (function) | |||||||||||||||||||||||||||