TRS80 Color Basic Quickref
TRS80 Color Basic Quickref
out a FOR.•TO Creates a loop in program which the Computer must LINE INPUT Input line from keyboard. PRINT#·l Writes data to cassette. REM Allows insertion of comment in program line. Everything
Statements machine-language file. STEP/ repeat from the first number to the last number you specify. LINEINPUTANSWER"IX$ PRINTA$ after REM is ignored by Computer.
CSAVEM"X",4E,SF,5F NEXT Use STEP to specify how much to increment the number ? A$ REM TH I SIS IGNORED
AUDIO Connects or disconnects cassette output to TV MID$ (oldstr, position, length) Replaces a portion of on,~ 10 ?){$ :REM IGNORE
each time through the loop. If you omit STEP, one is used. PRINT#-1,A
speaker. DATA Stores data in your program. Use READ to assign this string with another string.
FOR }(=2 TO 5 : NE><T ~<
AUDIDDN data to variables. MID$ (A$t14,2)="KS" PRINT#-2 Prints an item or list of items on the printer. RENUM aewllne, startllae,lacreDleat Allows program line
FDRA=1 TO 10STEP5 :NE)<TA
AUDIO OFF DATAS ,3 ,PEARS PRINT#-2,CAP$ renumbering.
FOR M=30 TO 10 STEP -5: NUn M MOTOR Turns cassette ON or OFF.
DATA PAPER, PEN RENUM 1000 ,5 1100
CIRCLE (Jr,Y}~~,h"".''''',ead Draws a circle with center at MOTOR ON PRINT TAB Moves the cursor to specified column position.
GET (start)-(ead), d_tlaatloa, G Reads the graphic RESET (x,v) Resets a point.
point (x,y) radlu , specified color c, height/width ratio (hw) of DEF FN Defines numeric function MOTOR OFF PRINTTAB(S) "NAME"
contents of a rectangle into an array for future use by PUT. RESET (111 ti5)
0-4. Circle can start and end at specified point (0-1). DEF FN (X) = X * 3
GET (5,20)-(3,8),V ,G NEW Erases everything in memory. I', PRINT USING Prints numbers in specified format.
CIRCLE(128,8S),50,4t1,.5,.75 JJ DEFUSR a Defines entry point for USA function n. n = 0-9. NEW # Formats numbers. RESTORE Sets the Computer's pointer back to first item on the
GOSUB Calls a subroutine beginning at specified line number. firstDATA line.
CLEAR a,h Reserves n bytes of string storage space. Erases DEFUSR5=45S43 PRINTUSING" •••• "IG2.2
GOSUB 500 ON•••GOSUB Multi-way branch to call specified subroutines.
RESTORE
variables. h specifies highest BASIC address. DEL Deletes program lines. ON Y GOSUB 50,100 Decimal point.
CLEAR GOTO Jumps to specified line number. PRINTUSING" ...... 158.G RETURN Returns the Computer from subroutine to the BASIC
DEL-
CLEAR 500 GOTO 300 ON.•.GOTO MUlti-way branch to specified lines. Displays comma to left of every third character.
DEL25 word following GOSUB.
CLEAR 101', , 111000 DEL 25- IF TEST THEN ..• ELSE action 1, action 2 Performs a test. ON){ GOTO 190 ,200 PRINTUSING" •• ##,"144.0 RETURN
DEL -25 IF it is true, the Computer executes action 1. If false, action 2 is ++ Fills leading spaces with asterisks.
CLOAD Loads specified program file from cassette. If file name OPEN m,#d,f Opens file (f) at: Screen or Keyboard (0); RUN Executes a program.
DEL 10-25 executed. PRINTUSING"**# •••• "133.3
is not specified, first file encountered is loaded. File name must Cassette (-1); Printer (-2). For input (I), or output (0). RUN
IFA=5THEN30 $ Places $ ahead of number.
DIM Dimensions one or more arrays. OPEN "0" ,-1, "DATA"
be eight character/spaces or fewer. PRINTUSING"$## ••• "133,3 SCREEN screea-type, color·set Selects either graphics (1)
CLOAD OIMR(6S) ,W(1l0) INPUT Causes the Computer to stop and await input from the
$$ Floating dollar sign. or text (0) screen and color-set (0 or 1).
PAINT (.,V),I:," Paints graphic screen starting at point (x,y)
CLOAD"PROGRAM" DIMAR$(8,2S) keyboard. SCREEN 1,1
with specified color c and stopping at border (b) of specified PRINTUSING"$$ •••• "111.S411
I NPUT)<$
CLOADM Loads machine-language program from cassette. DLOAD Loads BASIC program at specified baud. color. **$ Floating dollar sign. SET (x,V,c) Sets a dot at specified text screen location to
INPUT "NAME"; N$
baud. PAINT (10,10) ,2,lI PRINTUSING"**$ ••• #"18.333
MD offset address to add the loading address may be specified. specified color.
0= 300 baud 1 = 1200baud INPUT#-l Inputs data from cassette. ri-- In first position, causes sign to be printed. In last SET( 111 ti3 ,3)
CLOADM"PROG" PCLEAR a Reserves n number of 1.5 K graphics memory
DLOAD "X" , 1 INPUT#-1,A position, causes sign to be printed after the number.
CLOADM pages. SKIPF Skips to next program on cassette tape, or to end of
CLOADM " PROG" , 1000 -~ DRAW Draws a line beginning at specified starting point of INSTR (posltloa, search, target) Searches for the first PCLEAR 8
PRINTUSING"+ ••• #"i-21G
.. ~\...... Exponential format. specified program.
CLOSE d Closes open files. specified length of specified color. Will also draw to scale, draw occurrence of target string in search string beginning at position. SKIPF"PROGRAM"
PCLS c Clears screen with specified color c. If color code is PRINTUSING"··.·tttt"ISllG
CLOSE blank lines, draw non-updated lines, and execute substrings. If Returns the position at which the match is found.
?INSTR(5,X$,Y$) omitted, current background color is used. (See CLS for co or Minus sign after negative numbers. SOUND tone, duration Sounds specified tone for specified
CLOSE-2 starting point is not specified, last DRAW position or (128,96) is
codes.) PRINTUSING".# •• -"1-5311.7 duration.
used. LET Assigns value to variable (optional).
CLS c Clears display to specified color c. If color is not PCLS 3 Returns first string character. SOUND 128,3
DRAW"BM100,100IS10IU25IBR25IND25IXA$I"
specified, green is used. LET A$ = "JOB A" PR I NT US I NG .. ! " I" YELLOW"
EDIT Allows editing of program line. PCOpy Copy graphics from source page to destination page. Ofosp8cesOfo String field; length of field is number of spaces STOP Stops execution of a program.
O-Black LIST Lists specified line(s) or entire program on screen.
nC Changes n number of characters. PCOPY 5 TO G plus 2. STOP
l-Green 5-Buff LIST
2-Yellow 6-Cyan nO Deletes n number of characters. LIST50-85 PLAY Plays music of specified note (A-G or 1-12), octave (0),
PRINT USING"'X. x.. ; "BLUE" THOFF Turns off program tracer.
3-Blue 7-Magenta I Allows insertion of new characters. LI ST 30 TROFF
volume (V), note-length (L), tempo (T), pause (P), and allows PRINT @location Prints specified message at specified text
4-Red 8-0range H Deletes rest of line and allows insert. LIST-30 execution of substrings. Also sharps (# or + ) and flats (- . screen location. THON Turns on program tracer.
CLS L Lists current line and continues edit. LIST30- PLAY"L1iA.;P8IV10IT3;L2iB-i9iXA$i" PRINT@256,"HI" TRON
CLS 3 nSc Searches for nth occurrence of character c. PRINT@256,A$
X Extends line. LUST List specified program line(s) or entire program to printer.
COLOR (lore _d, "adtgroaad) Set foreground PMODE DIode, start-page Selects resolution and first
tIBIEIl(j) Escape from subcommand. LLIST PSET (.,v,c) Sets a specified point (x,y) to specified color c. If c
and backgroun color. memory page.
n (SPACEBAR) Moves cursor n spaces to right. LLIST 50-85
PMODE 4,1
is omi ted, foreground is used.
COLOR,1,3 n S Moves cursor n spaces to left. LLI ST 30 PSET 5,6,3)
CONT Continues program execution after pressing (BREAK) or ED IT 25lEBIE1ll LLIST-30 POKE (location, value) Puts value (0-255) into specified PUT (sta;rt}-(end), source, actloa Stores graphics from
using STOP scatement. LLIST30- memory location.
END Ends program. source onto start/end rectangle on the screen. (Array rectangle
CONT END LINE (Jrl,yl)-(d,v2), PSET or PRESET, SF Draw a line POKE15872,255 size must match GET rectangle size.)
CSAVE Saves program on cassette (program name must be from (x1.y1) to (x2,y2). If (x1,y1) is omitted, the last end point or PUT (3,2)-(5,6) ,V ,PSET
EXEC (address) Transfers control to machine-language (128,96) is used. PSET selects foreground color and PRESET PRESET Reset a point to background color.
eight character/spaces or less). If A is specified, program saved programs at specified address. If address is omitted, control is PRESET (5,6) READ Reads the next item in DATA line and assigns it to
is ASCII format. selects background color. ,B draws a box with (x 1,yt) and
transferred to address set in last CLOADM. specified variable.
CSAI.IE "PROGRAM" (x2,y2) as the opposing corners. ,SF will fill in the box with
E~<EC PRINT Prints specified message or number on TV screen. READ A$
CSAI.JE "PROGRAM" ,A foreground color.
E){EC 3211S3 PRINT "HI" READC,B
LINE(5,3)-(S,S) ,PSET
TRS·BO ® Video Control Codes Functions JOYSTK OJ Returns the horizontal or vertical coordinate U) of
the left or right joystick:
STRlNG$ (Ieagt/J.eode or strlag) Returns a string of
characters (of specified length) specified by ASCII code or by the
Special Characters
o = horizontal, left joystick first character of the string.
Color Computer 2 Dec Hex PRINT CHR$ (code) 1 = vertical, left joystick
2 = horizontal, right joystick
?STRING$(5,l',t" )
?STRING$(S,91)
$
Abbreviation for REM.
Makes variable string type.
8 08 Backspaces and erases current character. Separates statements on the same line.
MICRO· 13
32
00
20
Line feed with carriage return.
Space
Argument ranges are indicated by special symbols:
numeric: (_10 38, + 10 38)
3 = vertical, right joystick
M=JOYSTK(0)
STR$ (numeric)
S$=STR$ (){)
Converts a numeric expression to a string. ? Same as PRINT.
.
H=JOYSTK(K) PRINT punctuation: spaces over
x: (0-255)
COMPUTER y: (0-191) lEFT$ (str,length) Returns left portion (length characters) of
SQR (aamerie)
Y=SQR(5+3)
Returnsthesquarerootofanumber. to the next 16-column PRINT zone.
PRINT punctuation: separates items in a
location: (0-65535) string.
PRINT list but does not add spaces
SYSTEM code: (0-255)
str: string argument
P$=LEFT$(M$,7) AN (aamerie)
Y=TAN(4S.7)
Returns tangent of angle given in radians.
when they are output.
lEN (str) Returns the length of a string.
var: variable name ){=LEN (SEN$) Returns contents or allows setting of timer (0-65535).
Operators ABS (numeric)
Y=ABS(S)
Computes absolute value.
l.OG (aamme) Returns naturallogarittim.
?TlMER
TlMER=0
Y=LOG(353)
Each operator or group of operators is ASC (str) Returns ASCII code of first character of specified SRa (aamerie) Calls user's machine-language subroutine.
\lEM Finds the amount of free memory. X=USR(Y)
precedent over the group below it. string.
PRINTMEM
A=ASC (1$)
VAL (str) Convertsastringtoanumber.
+ Exponentiation ATN (......erie) Returns arctangent in radians.
\lID$ (str. pos.length) Returns a substring of another string
starting at pas. If length is omitted, the entire string right of
A=t,JAL (B$) Error Messages
-,+ Unary negative, positive y= ( 3 VARPTR (var) Returns address of pointer to the specified Abbreviation Explanation
position is returned.
*,1 Multiplication, division CHR$ (code) Returns character for ASCII, control, or graphics F$=MID$(A$,3) variable. /0 Division by 0
+,- Addition and concatenation, subtraction code. ?MID$(A$ ,3 ,2) Y=USR(VARPTR(X) )
AD File already OPEN
<,>,=,<=,>=,<> Relational tests ?CHR$(191) BS Subscript out of range
EEK (Ioeatloa) Returns the contents of specified memory
P$=CHR$(T) CN Can't continue
location.
cos (......eriel Returns cosine of an angle given in radians. A=PEEK(32076) DD Redimensioned array
Y= () DN Device number error
POINT (x,y) Tests whether specified graphics cell is on or off, x DS Direct statement in file
EOF (f)
Start-Up Returns FALSE (0) if there is more data:TRUE(-1) if
end of file has been read. For cassette, (= - 1; for keyboard,
(horizontal) = 0-63; Y (vertical) = 0-31. Thevalue returned is -1 if
the cell is in a text character: mode: 0 if it is off, or the color code if
FC Illegal function call
01 21 31 4
6. Turn the Computer ON. Interrupts anything in progress and OD Out of data
FIX (a....erie) Returns truncated (whole number) value. and returns color code of specified cell. returns to command level.
Y=FIX<7.6)
OM Out of memory
7. If you're not using a Program Pak'·, the Color BASIC or 5 PPOINT (13,35)
OS Out of string space
Extended Color BASIC start-up message will appear on the TV, HEX$ (aamerie) Computes hexadecimal value. RIGHT$ (str,length) Returns right portion of string. Clears the screen. Ot.' Overflow
61 71 81 91 10
followed by: OK
PRINTHEX$ (30) ZIP$=RIGHT$(AD$,S) RG RETURN without GOSUB
The Computer is now ready to use. Signifies end of current line.
v=HEX$ (XL161 SN Syntax error
SGN (numeric) Returns sign of specified numeric expression:
Note: Information pertaining to Extended Color BASIC only is INKEY$ Checks the keyboard and returns the key being - 1 if argument is negative (SPACEBAR) Enters a space (blank) character and ST String formula too complex
shaded Iil<e this paragraph. Non-shaded information pertains to pressed (if any). o if argument is 0 moves cursor one space forward. TM Type mismatch
both Extended and non-Extended Color BASIC.