
Tandy CoCo BASIC
[**tested] means I have tested this command/function on Extended Color BASIC
1.1 and on 2.0
ASC (str)
- Returns ASCII code of first charactr of specifed string.
Example:
A = ASC( T$ )
CLS c
– Clears screen, optionally filling it with a color (0-8).
CLS c Clears display to specified color c. If color is not specified, green
is used.
0-Black
1-Green
2-Yellow
3-Blue
4-Red
5-Buff (white)
6-Cyan
7-Magenta
8-Orange
Example:
CLS 7
COLOR (forground,background)
- Sets forground and background color.
Example:
COLOR 1, 3
CONT
- Continues program execution after pressing or (break) useing STOP statement
DRAW "string"
- Draws a line beginning at specified starting point of specified length of
specified color. Will also draw to scale, draw blank lines, draw non-updated
lines, and execute substrings. If starting point in not specified, the last
DRAW position or default of (128,96) is used.
Example:
DRAW "BM100,100;S10;U25;BR25;ND25,XA$;"
Movement Commands
The DRAW command uses specific character codes to determine direction and
movement:
Un: Up
Dn: Down
Ln: Left
Rn: Right
En: Diagonal Up/Right
Fn: Diagonal Down/Right
Gn: Diagonal Down/Left
Hn: Diagonal Up/Left
"n" represents the number of pixels to move.
For example, DRAW "U10 R5" moves the cursor 10 pixels up and then 5 pixels
right.
Special Control Commands
M x,y: Move to absolute coordinate (x,y) or relative (+x,+y) if a + or - sign
is used.
B: Move without drawing (Blank). E.g., DRAW "BU10" moves up 10 pixels without
plotting them.
Like with the U and other movement commands, B and M can be combined as for
example:
DRAW "BM100,100"
N: Move and draw, but return to the original position afterward (No-update).
For example, drawing down for 25:
DRAW "ND25"
Cn: Set color (n = 0-3 for CoCo 1 and 2, or higher with CoCo 3 palettes).
Sn: Set scale factor (n). Default is 4. Scale 1 is smallest, 255 is largest.
An: Set angle (n = 0, 1, 2, 3). 0=0°, 1=90°, 2=180°, 3=270°.
END
- Ends execution of BASIC code.
FOR and NEXT
- Create a stepped loop
Example:
10 FOR I = 1 TO 10
20 PRINT I
30 NEXT I
GOSUB
- Calls a subroutine beginning at specified line number.
Example:
GOSUB 500
GOTO
- Jumps to a specified line number.
Example:
GOTO 300
IF and THEN and ELSE
- check values for condtions
Example 1:
IF A=5 THEN 30
will jump to line 30 if the value of A is 5.
Example 2:
IF A>B THEN 100
will jump to line 100 if the value of A is greater than the value of B
Example 3:
IF X=10 THEN PRINT "YES" ELSE PRINT "NO"
INPUT var
- Takes input from keyboard
Example 1:
INPUT A$
This will read and store a string from the keyboard
INPUT D
This will read and store a number from the keyboard
MEM
- Finds the amount of free memory.
Example:
PRINT MEM
MID$ (str,pos,length)
- Returns a substring of another string starting at pos. If lenght is omitted,
the entire string right of position is returned.
Example:
F$ = MID$( A$, 3)
? MID$(A$, 3, 2)
PEEK
Example Command:
PEEK(116)
Result: Returns 127 in a 32K/64K System or 63 in a 16K System.
Remarks: Can be used to ascertain the memory size of a computer.
Example Command2:
PEEK(116) * 256 + PEEK(117)
Result: Returns maximum memory in System.
PLAY "string"
[**tested]
PLAY "note"
PlAY "length;note"
PLAY "volume;note"
MUSICAL NOTE/NUMBER
Number Note
1 C
2 C#/D
3 D
4 E-/D#
5 E/F
6 F/E#
7 F#/G
8 G
9 G#/A
10 A
11 A#/B
12 B
Note: PLAY does not recognize the notation B# or C-.
Play A note:
PLAY "A"
Add another note:
PLAY "A;A#"
Add pause
PLAY "A;P2;A#"
Change Volume
PLAY "V5;A;P2; V10;A;P2; V30;A;P2"
Change Note Length
PLAY "L2;A;L4;A;A;L2;A;A"
POKE (location, value)
- Puts value (0-255) into specified memory location.
Example:
POKE 25,6:POKE 26,1:POKE 1536,0:NEW
Makes maximum memory available for basic programs.
Any basic program in memory is cleared. Not compatible with disk systems.
Does not allow the use of graphics.
Example Command2:
POKE 280,PEEK(275)
Result: Helps COCO Generate 'TRUE' Random Numbers.
Remarks: Same as the Ext. Basic Statement
X = RND(-TIMER).
PRESET
- Reset a point to background color.
Example:
PRESET (5,6)
PRINT
- Prints specified message or number to screen.
Example:
PRINT "HI"
REM
- Non executed comment or a remark usually for documenting purpose.
RETURN
- Used to return to the place of the GOSUB
RND
- Creates a random number
Example:
RND(0)
Returns a random floating-point number between 0 and 0.99999999999999.
Example 2:
10 X = RND(-TIMER) :REM Seed the generator
20 FOR I = 1 TO 10
30 PRINT RND(10); :REM Print 10 random numbers between 1-10
40 NEXT I
SGN (numeric)
- Returns sign of specified numeric expression
SIN (numeric)
- Returns sine af angle gleen in radians
SOUND tone, duration
tone can be 1 to 255
duration can be 1 to 255
10 PRINT "TO MAKE ME CHANGE MY TONE"
20 PRINT "TYPE IN A NUMBER FROM 1 TO 255"
30 INPUT T
40 SOUND T, 50
50 GOTO 10
SOUND 1 , 100
SOUND 255, 100
STRINGS (length, code or string)
- Returns a string of characters (of specified length) specified by ASCll code
or by the first character of the string.
SQR (numeric)
- Square root of a number
Example:
Y=SQR(5+2)