Color BASIC
Color BASIC is the implementation of Microsoft BASIC that is included in the ROM of the Tandy/Radio Shack TRS-80 Color Computers ("CoCos") manufactured between 1980 and 1991. BASIC (Beginners All-purpose Symbolic Instruction Code) is a high level language with simple syntax that is easy for novices to write simple programs. BASIC is interpreted, that is, decoded as it is run. Becuase of this, it is simple to edit and debug but its performance is significantly less than a compiled languge such as C or assembly language.
Background
Color BASIC 1.0 was released with the original 4k TRS-80 Color Computer in 1980. It resides on 8k bytes of ROM, and is responsible for all 'housekeeping' duties on the system. This includes hardware initialization, memory management, etc. Like most implementations of BASIC, each line of code starts with a line number and consists of one or more statements with variables and operators.
16k of memory is required for the next level of BASIC, Extended Color BASIC. ("ECB")
Extended BASIC is required for the floppy disk controller, which then gives you Disk Extended Color BASIC. ("DECB")
Variables
Color BASIC understands one type of numeric variable and string variables. Variable names in Color BASIC have the first two characters significant. The first character of the variable name must be a letter. The second can be either a letter or number. String variables are indicated by adding a dollar sign ($) after the variable name.
Examples
A=5
A$="THIS IS A STRING"
K7=10
BB$="HELLO!"
ZZ=1.54
Multidemensional arrays are also supported with both numeric and string variables. In the case of an array, the element address is enclosed with a parenthesis:
A(1)=1
A$(1)="BOOKS"
Multiple dimensions are separated by commas
A(1,3)=4
A$(2,2)="XYZ123"
Operators
Color BASIC provides several operators for both mathematic and (to a lesser extent) string operations
+ can be used to concatenate strings or for mathematical addition
- is used for subtraction
* is used for multiplication
/ is used for division
Parenthesis ( ) are used to override mathematical order of operation
AND is used for logical 'and' operations
OR is used for logical 'or' operations
NOT is used for logical 'not' operations
For testing, the following operators are used:
= is equal to
> is greater than
< is less than
>= is greater than or equal to (also => is acceptable)
<= is less than or equal to (also =< is acceptable)
<> is not equal to (also >< is acceptable)
Command list
ABS(num)
ASC(str)
AUDIO [ON|OFF]
CHR$(num)
CLEAR variable space[,highest memory location]
CLOAD ["name"]
CLOADM ["name"]
CLOSE [device number]
CLS(num)
CONT
CSAVE ["name"]
DATA var,var,var...
DIM variable(dimension[,dimension 2,...]
END
EOF(device number)
EXEC [memory address]
FOR {num} = {number} TO {number} [STEP {number}]
... NEXT {num}
GOSUB {line number}
GOTO {line number}
IF {test} THEN {command(s)} [ELSE {command(s)}]
INKEY$
INPUT [device number] [{prompt text};] variable [,variable 2, variable n]
INT(num)
JOYSTK(number)
LEFT$(str,position)
LEN(str)
LIST [starting line] - [ending line]
LLIST [starting line] - [ending line]
MEM
MID$(str,starting position,length)
MOTOR [ON|OFF]
NEW
ON {num} GOSUB line 1, line 2, ... line n
ON (num) GOTO line 1, line 2, ... line n
OPEN "[I|O]",device number[,"filename"]
PEEK(memory address)
POINT(x,y)
POKE memory address, data
PRINT expression
PRINT@{screen position} expression
READ variable[,variable,...]
RESET(x,y)
RESTORE
RETURN
RIGHT$(str,position)
RND(number)
RUN
SET(x,y,color)
SGN(num)
SIN(num)
SKIPF ["filename"]
SOUND tone,duration
STOP
STR$(num)
TAB(column)
USR(num)
VAL(str)