| Color Basic |
Article Index for Color |
Website Links For Color |
Information AboutColor Basic |
| CATEGORIES ABOUT COLOR BASIC | |
| trs-80 color computer | |
| microsoft basic | |
| basic programming language family | |
|
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 Numeric variables have only one type, a binary floating point implementation. Each numeric variable consumes 5 bytes of memory and can be in the range from 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 AND SYMBOLS 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 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) Other symbols used in BASIC: " " indicates string data is a constant (static) : separates multiple commands on a single program line ( ) overrides normal order of operations for a mathematical calculation A semicolon, when encountered in a PRINT function, will cause the output to remain on the same line A comma, when encountered in a PRINT function, will tab to the next column KEY ''num'' indicates a numeric expression is required. This can be a fixed number, a variable, or other operation or function that returns a numeric quantity. ''str'' indicates a string expression is required. This can be a static string value (in quotes), a string variable, or other function or expression that returns a string of characters. ''device number'' indicates a device. By default, device 0 (screen and keyboard) is assumed. In Color BASIC, device #-1 (cassette) and #-2 (printer) are available to the programmer. FUNCTIONS ABS(''num'') returns the Absolute Value of ''num'' ASC(''str'') returns the ASCII code of the first character in ''str'' CHR$(''num'') returns a single string character with the ASCII code ''num'' EOF(''device number'') returns 0 if the file has data, or -1 if at the end of the file INKEY$ returns a character if a key on the keyboard has been pressed, or null if nothing is pressed INT(''num'') returns the integer portion of ''num'' JOYSTK(''num'') returns the position of the joystick axis (0-3) with a value from 0 to 63 LEFT$(''str'',''num'') returns the first ("left") ''num'' characters of string ''str'' LEN(''str'') returns the length (in characters) of string ''str'' MEM returns the available free memory in bytes MID$(''str'',''start num'',''length num'') returns a sub-string of string ''str'' beginning at position ''start num'' and ''length num'' characters long PEEK(''num'') returns the value of the memory location ''num'' (0-65535) POINT(''x num,y num'') returns the color of the semigraphics dot at position ''x numm'' (0-63) and ''y num'' (0-31) RIGHT$(''str'',''position num'') returns the end ("right") portion of string ''str'' beginning at character ''position num'' RND(''number'') returns a random number (integer) between 1 and ''num'' SGN(''num'') returns the sign of a number ''num'', 1 if positive, -1 if negative, 0 if 0 SIN(''num'') returns the sine of ''num'' in radians STR$(''num'') returns a string of the number ''num'' USR(''num'') calls a machine language subroute whose address is stored in memory locations 275 and 276. ''num'' is passed to the routine, and a return value is assigned when the routine is done COMMANDS | ||
|   | '''MOTOR | "ONOFF" class="copylinks" target="_blank">{Link without Title} ''' turns the cassette motor on or off<br> |
|   | '''OPEN " | "IO]",''device" class="copylinks" target="_blank">number''[,"''filename''" ''' opens a device for communication<br> |
|
|