BASIC 1.0 is the standard BASIC language for Thomson computers (MO5, TO7, etc.), which is the reference for the entire range. This is an implementation of Microsoft BASIC (BASIC-69). On the MO5, the instruction set is reduced and the double precision is not implemented, so that the interpreter fits in only 12 KB of ROM, instead of 16 KB on the TO7.
Type | Name | Range |
---|---|---|
Integer | AB% | -32768 to +32767 |
Real | AB | +/- 9.99999 E +38 |
String | AB$ | 0 to 255 characters |
Where A must be a letter, B and following (up to 255) characters are optional and may be a letter or digit. Only the first 15 characters are significant.
Symbol | Operation |
---|---|
( ) | Grouping |
- | Negation |
^ | Exponentiation |
* / | Multiplication (*) and division (/) |
@ MOD | Integer division (@) and modulus (MOD) |
+ - | Addition and subtraction |
> < = <> >= <= | Relational operators |
NOT AND EQV IMP OR XOR | Logical operators |
A | B | A AND B | A EQV B | A IMP B | A OR B | A XOR B |
---|---|---|---|---|---|---|
0 | 0 | 0 | -1 | -1 | 0 | 0 |
0 | -1 | 0 | 0 | -1 | -1 | -1 |
-1 | 0 | 0 | 0 | 0 | -1 | -1 |
-1 | -1 | -1 | -1 | -1 | -1 | 0 |
Continues program execution after a STOP statement or pressing the STOP key.
Deletes program lines.
DELETE 100-350 |
DELETE 10- |
DELETE -80 |
Displays all or specified lines of the program currently in memory. By default, LIST displays its output on the screen, but a device can be specified.
LIST |
LIST 10-95 |
LIST -200 |
LIST "LPRT:(80)" - Prints program in 80 column mode. |
file
[,R]]
Merges the BASIC program on tape or disk with program in memory. Runs program if ,R
is given
Clears program from memory.
Executes a program starting at lowest line, specified line or loads program from tape to run. Closes all files unless ,R
is given.
RUN |
RUN 250 |
RUN "startrek" |
RUN "format",R |
Turns on/off program flow trace.
X,Y
Defines the height and width of the characters. The possible values are 0 and 1.
I
[,J
[,K
]]
Erases all variables and reserves space for string storage, highest address for BASIC and graphical characters.
CLEAR 500 |
CLEAR 200,25000 |
Clears display
top,bottom
Reserves the lines between top and bottom for text.
CONSOLE 5,15 |
CONSOLE 0,24 |
Stores data in program for use by READ statement
DATA January, 31, "Martian History Month". |
A
[,B
...]
Declares the type of a variable as either integer, real or string.
DEFINT A-B,O-Q defines A,B,O,P and Q as integer |
VARNAME
(SIZE 1
[,SIZE2
...])
Dimensions one or more arrays.
DIM X(40),A$(7,6),B(10,2) |
Terminates program execution. This statement is not required at the end of a program because control flow will end automatically there.
When an error has occurred, the function ERR gives the code number and ERL gives the line number in which the error occurred.
N
Makes it possible to simulate error number N
.
address
Transfers control to machine language programs at address
.
VARNAME
= START
TO END
[STEP INCREMENT
]
Creates a program loop which is executed, for specified range of values, STEP indicates the increment. If STEP omitted, one is used.
Calls subroutine beginning at specified line number.
Causes immediate program branch to specified line number.
condition
THEN action 1
ELSE action 2
Tests condition. If true performs action 1 and jumps to next line, if false performs action 2.
PROMPT
;] VAR1
, VAR2
Causes program to halt for entry from keyboard. The optional prompt string is followed by a question mark and a space. The user may then enter a series of values separated by commas.
INPUT"ENTER NAME";N$ |
INPUT A,B,C,D |
VAR
= EXPR
Assigns value to variable. LET is not implemented. Use implied assignment.
A=42 |
Hw$="HELLO WORLD" |
Allows input of line from keyboard, including commas. Line is terminated by [ENTER].
I,J,K
Place the cursor at location I,J
VARNAME
]
Returns control to a FOR statement to determine whether the loop should be repeated. If the termination condition has not been met, control will proceed with the line following the FOR statement. If the termination condition has been met, control will proceed with the statement following the NEXT.
EXPR
GOSUB
LABEL1
[,LABEL2
...]
Multiway branch to specified lines.
Upon encountering a RETURN statement, control will return to the statement following the ON GOSUB.
The value of EXPR
is rounded up or down to the nearest integer, and is used as an index into the list of labels, starting with 1.
If the index is less than 1 or greater than the number of labels, control falls through to the next statement.
ON I GOSUB 100,200,300 |
EXPR
GOTO
LABEL1
[,LABEL2
...]
Multiway branch to specified lines. The value of EXPR
is rounded up or down to the nearest integer, and is used as an index into the list of labels, starting with 1.
If the index is less than 1 or greater than the number of labels, control falls through to the next statement.
ON K GOTO 245,187,310 |
Directs control to the specified line if a subsequent error is detected.
ON ERROR GOTO 5000 |
location,value
Places value in specified memory location. Value must be 0 - 255.
EXPR1
[;|,]EXPR2
[;|,]...]
Prints content of following list on screen. Expressions can be ended with semicolons, commas or nothing. Comma causes tab to next 12 column print zone. Semicolon holds print head position. '?' is a synonym for PRINT.
PRINT"THE ANSWER" |
PRINT A,B |
PRINT "YOU'VE HAD";T;"TRIES" |
X
)
Moves the cursor to the position given in X
. If the cursor is already past, then moves to next line first.
Prints output in specified format.
# number field |
$ dollar sign in front of number. |
* fills leading spaces with asterisks. |
^ prints in exponential format. |
+ causes sign to be printed. |
VAR1
[,VAR2
...]
Assigns the next item in a DATA statement to specified variable.
TEXT
Allows comments to be inserted in a program. Everything in a line following REM is ignored. The quote (') is a synonym for REM.
LABEL
]
Resets the data pointer back to the first item in the first DATA statement or the statement at the specified line number.
RESTORE |
RESTORE 200 |
Return to the main program after execution of error subroutine.
Returns the program from subroutine to the statement following GOSUB.
Halts execution of program at line containing STOP. Variables are not cleared, so that they can be inspected for debugging purpose. Use CONT to continue execution.
X$
)Returns ASCII code of first character in string
N
)Returns character for specified ASCII code value.
A$ = CHR$(93) |
Checks keyboard and returns key being pressed. If no key is pressed then returns the empty string.
N
,X$
,Y$
)Searches for first occurrence of target string Y$
at a position N
.
Returns position of match.
P = INSTR(8,A$,"TED") |
X$
,N
)Returns the first N
characters of string X$
.
B$ = LEFT(A$,9) |
X$
)Returns the length of string X$
.
K = LEN(K$) |
X$
,
N
[,M
])Returns substring of X$
of length M
, starting from position N
. If M
is missing, then substring from N
to end is returned.
B$ = MID$(A$,4,1) |
X$
,N
)Return the last N
characters of string X$
.
B$ = RIGHT(A$,9) |
N
)Converts N
to its string representation.
X$ = STR$(14.4) |
X$
)Converts numeric characters of X$
to a number.
P = VAL(D$) |
X
)
Computes absolute value of argument.
X
)
Returns cosine of angle given in radians.
Return the line the cursor is at.
X
)
Returns exponential of number.
X
)
Returns truncated value.
A$
)
Returns the amount of memory available for programs or strings.
X
)
Converts number to integer.
X
)
Returns natural logarithm of argument.
X
)
Returns content of specified memory location X.
D
)
Returns the horizontal position of the cursor of device D
.
X
)]
Generates random number between 0 and 1. If X
is negative, then seeds the random number generator.
X
)
Returns sign of number as: 1 positive, 0 zero, -1 negative.
X
)
Returns sine of angle given in radians.
X
)
Writes X
spaces.
X
)
Returns square root of number. Argument must be non-negative.
X
)
Returns tangent of angle given in radians.
X
)
Returns address of pointer to specified variable.
Closes open files.
CLOSE 1,3 |
channel
)
Returns -1 if end of file has been reached
CHANNEL
Read from file opened with OPEN.
CHANNEL
Allows input of line from open file, including commas. Line is terminated by [ENTER].
Load program file from tape. First file encountered will be loaded, unless program name is specified.
LOAD |
LOAD "NAME" |
LOAD "NAME",R |
Load machine language program from tape. Offset to loading address main be given.
LOADM |
LOADM"NAME" |
LOADM"NAME",&H6000 |
Turns tape motor on/off.
A
,#CHANNEL
,FILENAME
Opens a file or device. The argument A
must be either "I" for input or "O" for output. CHANNEL
must be between 1 and 16.
The FILENAME
specifies device
("KYBD:" - keyboard, "SCRN:" - screen, "LPRT:" - line printer, "CASS:" - cassette tape) and if relevant, a file name on the device.
Device defaults to CASS:.
OPEN "I", #1, "CASS : FILE.TWO" |
CHANNEL
Prints content of following list to the specified file.
CHANNEL
USING
Prints formatted output to the specified file.
Transfer BASIC programs from memory to tape.
SAVE "prog" |
SAVE "prog",A |
Transfer machine code to tape.
SAVEM "codefile",&H6200,&H7520,&H6210 |
Skips to end of specified program on tape.
SKIPF |
SKIPF"NAME" |
X1,Y1
)-(X2,Y2
),C
Draws a box with corners at (X1,Y1) to (X2,Y2) in colour C.
X1,Y1
)-(X2,Y2
),C
Draws a filled box with corners at (X1,Y1) to (X2,Y2) in colour C.
foreground,background,invert
Sets foreground and background colours. If invert
is given then foreground and background are swapped.
N
)
Define a graphics character. N must be from 0 to 127.
DEFGR$(0) = 24,24,255,24,60,36,36,36 |
X1,Y1
)-(X2,Y2
),C
Draws a line from (X1,Y1) to (X2,Y2) in colour C
.
LINE (100,100)-(300,150),2 |
LINE -(0,150),2 |
LINE (0,10)-(30,10) "+",3,0 |
X,Y
)
Returns the color of the foreground if the pixel is set, otherwise the background.
X,Y
),C
Sets point X,Y to colour C. If C is positive, the pixel colour is set, otherwise the background colour.
foreground,background,border
Sets the colour scheme for the whole screen.
Prints the content of the screen.
X,Y
Reads the X,Y coordinate of the lightpen. X,Y are set to -1 if the lightpen is not detected.
X,Y
Reads the X,Y coordinate of the lightpen at the time the lightpen button is pressed. X,Y are set to -1 if the lightpen is not detected.
This function indicates the state of the lightpen interrupt.
For tuning the lightpen
PC key | NORMAL | BASIC |
---|---|---|
Pause/Break | STOP | INSTR |
Home | BACK | MERGE |
Delete | EFF | SAVE |
Insert | INS | |
Control | CNT | |
Escape | RAZ | CLS |
SHIFT (left) | SHIFT | |
SHIFT (right) | BASIC | |
F11 | ACC | INKEY$ |
Number | Code | Explanation |
---|---|---|
1 | NF | NEXT without FOR. Usually occurs when NEXT statements are reversed in a nested loop. |
2 | SN | Syntax Error. Usually caused by typing errors or incorrect punctuation. |
3 | RG | RETURN without GOSUB. Program has most likely fallen through the end of the routine, (use END) or a branch has been made into the subroutine. |
4 | OD | Out of Data. A READ statement has read all the DATA statements. |
5 | FC | Illegal Function Call. Usually parameter is out of range or the wrong variable type. |
6 | OV | Overflow. The number is too large for the computer to handle. |
7 | OM | Out of Memory. All available memory is being used or has been reserved. |
8 | UL | Undefined Line. A branching statement has been directed to a line that does not exist. |
9 | BS | Bad Subscript. Usually because the value of subscript is greater than the declared dimension of the array. |
10 | DD | Attempt to redimension an array. Arrays can only be dimensioned once in a program. |
11 | /0 | Division by zero. Not possible. |
12 | ID | Illegal Direct Statement. Attempt to use a statement which can only be used in a program e.g. INPUT. |
13 | TM | Type Mismatch. Attempt to assign string data to numeric variable or vice versa. |
14 | OS | Out of String Space. Use CLEAR to create more space if available. |
15 | LS | String too long. Maximum is 255 characters. |
16 | ST | String formula too complex. Break the operation into smaller steps. |
17 | CN | Can't Continue. Trying to use CONT when at END of a program. |
18 | UF | Undefined User Function. |
19 | NR | No RESUME. The RESUME instruction is required if an ON ERROR GOTO is located in the program. |
20 | RE | RESUME Without Error. |
21 | EC | ERROR with illegal error code argument. |
22 | MO | Missing Operand |
23 | FN | For Without Next. |
50 | NU | Not In Use. |
51 | FM | Bad File Mode. Trying to INPUT from a file which is OPEN for output (O), or PRINT data to a file OPEN for input (I). |
52 | AO | Attempt to open a file which is already open. Usually appears after pressing STOP to stop a program using files. |
53 | IO | Input/Output Error. Cassette not adjusted correctly or bad tape. |
54 | IE | Input Past End. Attempt to input past the end of a file. Use EOF function to check this does not happen. |
55 | FD | Bad File Descriptor. |
56 | DS | Direct Statement. Usually appears if you attempt to LOAD a data file. |
57 | NO | File Not Open. Input and output to a data file can only take place after OPEN. |
58 | BD | Bad Data. Caused by trying to read string data into numeric variable. |
59 | IU | Device In Use. |
60 | DU | Device Unavailable. |
61 | PP | Protected Program. |