Appendix A
BASIC at your elbow
When you remember that GET can pick something up but have forgotten what goes in the parentheses, start here. The PMODE graphics form picks up a rectangle. The disk form reads a record through an open file. A program can use both.
Find a command
Browse by first letter below, or search this volume. In the app, Read in BASIC Manual in BASIC Quick Reference brings you straight to the entry for the selected command or error. Each name here also has its own link, so you can go straight to PRINT USING, SDC-DOS DRIVE or JOYSTK. For a message that begins with a question mark, look up its error code.
A · B · C · D · E · F · G · H · I · J · K · L · M · N · O · P · R · S · T · U · V · W
How to read a form. Uppercase words are BASIC keywords. Replace names such as filename or number with your own value. Square brackets enclose an optional part. An ellipsis means the preceding item can repeat. The forms describe how to write a statement or expression. Files, devices and variables named in a form may need setting up first. When you want a complete exercise, follow its lesson or use the named example in Develop → BASIC Quick Reference….
Which machine? “CoCo 3 BASIC” includes commands provided by the extended interpreter in this machine. “Disk BASIC” needs the disk interpreter. The Hard Drive BASIC and CoCo SDC profiles add their own forms of some familiar commands. Compare the three ways to reach a disk before using a command that changes its contents.
Work out an expression
BASIC can do several jobs inside one expression. In ORDER.bas, guess both answers before running lines 20 and 30. Both use a two, a three and a four. The parentheses change which operation happens first.
10 WIDTH 40:CLS
20 PRINT 2+3*4
30 PRINT (2+3)*4
40 PRINT 2^3
50 PRINT 6/2-1
60 PRINT 4>3;4=3;4<>3
70 PRINT "RED"+" DUST"
80 PRINT (4>3) AND (2=2)
90 PRINT NOT (4>3)
100 END
The first two answers are 14 and 20. BASIC normally multiplies before adding. Parentheses let you ask for the sum first. The caret raises a number to a power. Two cubed is 8. The slash divides. Six divided by two, minus one, is 2.
The comparison signs ask questions. = asks “the same?”, <> asks “different?”, and <, >, <= and >= compare order. Line 60 prints −1, 0, −1 because the answers are yes, no and yes. In an IF test, zero is false and a nonzero result is true. With text on both sides, the plus sign joins the two strings. The space at the start of the second string puts a gap in RED DUST.
In line 80, the two comparisons each produce a true result. AND combines them and prints −1. In line 90, NOT reverses the result of the comparison and prints 0. AND, OR and NOT can also work on a number’s individual bits. If you mean to join two questions, put parentheses around each one as line 80 does.
A
ABS
Return the magnitude of a number.
ABS(number)
CoCo 3 BASIC · Count the supplies
In BASIC Quick Reference, open Numbers and rounding.
AND
Combine integer bit patterns; often used to join conditions.
expression AND expression
CoCo 3 BASIC · Choose a destination
AS
Give a string variable a field within a direct-access file buffer.
FIELD #file,length AS stringVariable
CoCo 3 BASIC · Keep a log past bedtime
See also FIELD.
ASC
Return the character code of the first character.
ASC(string)
The string must not be empty.
CoCo 3 BASIC · Give a chart its names
In BASIC Quick Reference, open Working with strings.
ATN
Return the arctangent in radians.
ATN(number)
Multiply by 180/PI to convert the result to degrees.
CoCo 3 BASIC · Count the supplies
ATTR
Choose text colors and optional character attributes.
ATTR foreground,background[,B][,U]
B enables blinking; U enables underlining.
CoCo 3 high-resolution text modes.
CoCo 3 BASIC · Design a flight deck
AUDIO
Connect or disconnect cassette playback sound from the CoCo audio output.
AUDIO ON
AUDIO OFF
Use the cassette transport and audio settings in VCC Plus to supply and hear tape playback.
CoCo 3 BASIC · Listen for a signal
B
BACKUP
Duplicate a BASIC disk onto another disk.
BACKUP source TO destination
BACKUP drive
Single-drive form requires disk exchanges.
Overwrites the destination disk. Use a new disposable image, never the only copy of your data.
Disk BASIC · Take the voyage to another machine
See also COPY.
BRK
Introduce a Break-key trap as part of ON BRK GOTO.
ON BRK GOTO line
CoCo 3 BASIC · Find the missing supply
See also ON BRK.
C
CHR$ · CIRCLE · CLEAR · CLOAD · CLOADM · CLOSE · CLS · CMP · COLOR · CONT · COPY · COPY — RGB-DOS · COS · CSAVE · CSAVEM · CVN
CHR$
Return the character with the specified code.
CHR$(code)
code: 0-255.
Control codes may move the cursor or change display behavior.
CoCo 3 BASIC · Give a chart its names
In BASIC Quick Reference, open Working with strings.
CIRCLE
Draw a circle, ellipse or arc on the PMODE screen.
CIRCLE(x,y),radius[,color[,ratio[,start,end]]]
ratio changes height relative to width.
start and end select fractions of a full turn.
CoCo 3 BASIC · Draw a planet you can find again
CLEAR
Clear variables and adjust string space or the BASIC memory ceiling.
CLEAR [stringBytes [, topAddress]]
stringBytes reserves string workspace.
topAddress leaves higher memory for machine-language code.
This discards current variable values; do not use it merely to clear the display.
CoCo 3 BASIC · Give a chart its names
See also MEM, OS — Out of string space.
CLOAD
Load a BASIC program from cassette.
CLOAD ["filename"]
Omitting the name selects the next BASIC program.
Cassette names have up to eight characters.
Loading replaces the program in CoCo memory. It does not open a Mac source document.
CoCo 3 BASIC · Take the voyage to another machine
CLOADM
Load a machine-language program from cassette.
CLOADM ["filename"[,offset]]
offset relocates loaded bytes; it does not rewrite addresses inside the program.
CoCo 3 BASIC · Take the voyage to another machine
CLOSE
Finish access to one or more open files.
CLOSE [#file[,#file ...]]
With no file number, close all open files.
Closing output files completes buffered writes.
Disk BASIC · Keep a log past bedtime
CLS
Clear the text screen.
CLS [color]
color chooses a text-screen background when supplied.
CoCo 3 BASIC · Make the CoCo answer
In BASIC Quick Reference, open Hello, CoCo.
CMP
Restore the standard composite palette on a CoCo 3.
PALETTE CMP
CoCo 3 BASIC · Draw a planet you can find again
COLOR
Choose foreground and background colors for PMODE graphics.
COLOR foreground,background
Available colors depend on the current graphics mode.
CoCo 3 BASIC · Draw a planet you can find again
CONT
Continue after an ordinary BASIC stop when the interpreter still has a valid continuation.
CONT
The editor Continue button resumes its debugger stop. It does not type this command.
Changing the program can invalidate BASIC's saved continuation.
CoCo 3 BASIC · Find the missing supply
See also STOP, CN — Cannot continue.
COPY
Copy one BASIC disk file to another filename or drive.
COPY "source/ext:drive" TO "destination/ext:drive"
Include the filename extensions.
Writes to the destination disk. RGB-DOS changes overwrite behavior; see its variant entry.
Disk BASIC · Take the voyage to another machine
See also COPY — RGB-DOS, BACKUP.
COPY — RGB-DOS
Copy a file, retaining its name when the destination is only a drive number.
COPY "source/ext:drive" TO drive
COPY "source/ext:drive" TO "destination/ext:drive"
Writes the destination. Direct mode asks before replacing an existing file; inside a BASIC program, replacement occurs without that prompt.
Hard Drive BASIC (RGB-DOS) · Take the voyage to another machine
See also COPY, DRIVE — RGB-DOS.
COS
Return the cosine of an angle in radians.
COS(angle)
Angles are radians, not degrees.
CoCo 3 BASIC · Count the supplies
CSAVE
Record the current BASIC program on cassette.
CSAVE "filename"[,A]
A selects ASCII rather than tokenized program storage.
Prepare the cassette recording transport first. Export the recording in VCC Plus to retain it as a Mac file.
CoCo 3 BASIC · Take the voyage to another machine
CSAVEM
Record a memory range as a machine-language cassette file.
CSAVEM "filename",first,last,entry
first and last are inclusive byte addresses; entry is the EXEC address.
Prepare cassette recording before issuing the command.
CoCo 3 BASIC · Take the voyage to another machine
CVN
Decode a five-byte BASIC number stored in a string.
CVN(string)
The string must contain the expected numeric encoding.
Disk BASIC · Keep a log past bedtime
See also MKN$.
D
DATA · DEF · DEF FN · DEF USR · DEL · DIM · DIR · DIR — SDC-DOS · DLOAD · DOS · DOS — RGB-DOS · DRAW · DRIVE · DRIVE NEW · DRIVE — RGB-DOS · DRIVE — SDC-DOS · DSKI$ · DSKINI · DSKO$
DATA
Place constant values in a program for READ.
DATA constant [, constant ...]
Use quotes around strings containing commas.
CoCo 3 BASIC · Give a chart its names
In BASIC Quick Reference, open Read a small data table.
DEF
Introduce a user-defined BASIC or machine-language function.
DEF FNname(argument)=expression
DEF USRn=address
CoCo 3 BASIC · Give a routine a job
DEF FN
Define a numeric function to evaluate later.
DEF FNname(parameter) = expression
FNname is invoked with a numeric argument.
CoCo 3 BASIC · Give a routine a job
In BASIC Quick Reference, open Numbers and rounding.
See also FN.
DEF USR
Set the entry address of a machine-language function.
DEF USRn = address
n: 0-9; the function must follow BASIC's machine-language calling convention.
CoCo 3 BASIC · Where BASIC meets the machine
DEL
Delete one or more lines from the CoCo's in-memory program.
DEL first[-last]
DEL -last
DEL first-
Use care: the interpreter does not provide Mac-style Undo for this command.
CoCo 3 BASIC · Make the CoCo answer
DIM
Reserve numeric or string arrays with inclusive upper bounds.
DIM name(upperBound [, upperBound ...]) [, ...]
Indices start at zero: DIM A(5) provides six elements.
Dimension an array before using it; do not dimension it twice.
CoCo 3 BASIC · Give a chart its names
In BASIC Quick Reference, open Array bounds and elements.
See also BS — Bad subscript, DD — Duplicate dimension.
DIR
List files stored on a BASIC disk.
DIR [drive]
Omit drive to list the default drive.
The listing shows name, extension, type, storage form and granule count.
In SDC-DOS, plain DIR still lists the mounted disk; DIR - browses the SD folder.
Disk BASIC · Take the voyage to another machine
In BASIC Quick Reference, open List the mounted disk.
See also DRIVE, DRIVE — RGB-DOS, DIR — SDC-DOS.
DIR — SDC-DOS
Browse the card folder instead of the files inside a mounted disk.
DIR -
DIR "path"
DIR = "path"
DIR = "/" selects the card root; DIR = ".." selects its parent folder.
Paths are relative to the SDC card folder selected in VCC Plus, not arbitrary Mac paths.
Plain DIR 0 still lists files inside the image mounted in drive 0.
CoCo SDC (SDC-DOS) · Take the voyage to another machine
In BASIC Quick Reference, open Browse and mount Hello Disk.
See also DIR, DRIVE — SDC-DOS.
DLOAD
Historical serial program-loading command.
DLOAD ["filename"]
Requires a compatible serial host and protocol.
The bundled CoCo 3 environment does not provide the historical DLOAD host service. Use native source opening or media loading instead.
CoCo 3 BASIC · Where BASIC meets the machine
DOS
Invoke a boot loader from drive 0.
DOS
Drive 0 must contain a compatible boot loader.
A boot loader can start another operating system or a program; DOS does not always mean OS-9.
Disk BASIC · Take the voyage to another machine
See also DOS — RGB-DOS.
DOS — RGB-DOS
Boot a selected BASIC volume, or try its AUTOEXEC program.
DOS [drive]
The NitrOS-9 preset boots automatically. Its running OS-9 shell is not a BASIC editor target.
Hard Drive BASIC (RGB-DOS) · Take the voyage to another machine
See also DOS, DRIVE — RGB-DOS.
DRAW
Draw PMODE graphics using a compact movement string.
DRAW string
U,D,L,R move in the four main directions; E,F,G,H move diagonally.
BM moves without drawing. C selects color, S scale and A angle.
X executes a string variable embedded in the drawing sequence.
CoCo 3 BASIC · Draw a planet you can find again
DRIVE
Choose the default drive for later disk commands.
DRIVE number
Disk BASIC uses drive numbers 0-3.
RGB-DOS and SDC-DOS extend this command in different ways.
Disk BASIC · Take the voyage to another machine
See also DIR, DRIVE — RGB-DOS, DRIVE — SDC-DOS.
DRIVE NEW
Create and mount a new disk image in the selected card folder.
DRIVE drive,"filename.DSK",NEW
Writes a new file; it does not replace an existing one.
Hardware documentation also covers SDF, flash, RTC and DriveWire features. These are not supported SDC features in VCC Plus.
CoCo SDC (SDC-DOS) · Take the voyage to another machine
See also DRIVE — SDC-DOS, DIR — SDC-DOS, DSKINI.
DRIVE — RGB-DOS
Switch between virtual hard-disk volumes and floppy drives.
DRIVE volume
DRIVE ON
DRIVE OFF [lastFloppy]
DRIVE #unit
volume: 0-255 selects a default virtual BASIC disk. With DRIVE OFF, drives 0-3 refer to floppy drives instead.
DRIVE OFF exposes floppy drives; DRIVE ON restores hard-disk routing.
#unit selects the hard-disk unit. VCC Plus has HD0 and HD1.
The Hard Drive BASIC preset uses RGB-DOS. Do not confuse a virtual BASIC volume number with an HD device number.
Historical DRIVE STOP and DRIVE RESTORE hardware operations are not needed for VCC Plus image files.
Hard Drive BASIC (RGB-DOS) · Take the voyage to another machine
In BASIC Quick Reference, open Floppy and hard-disk directories.
See also DRIVE, DIR, DOS — RGB-DOS.
DRIVE — SDC-DOS
Inspect, mount or unload images on the SDC card.
DRIVE
DRIVE drive,"path"[,volume]
DRIVE drive,UNLOAD
drive is 0 or 1; volume selects a BASIC volume inside a compatible hard-disk image.
Use short card filenames. A mounted image is a disk containing BASIC files, not itself a BASIC program.
The same image cannot be mounted in both drives.
CoCo SDC (SDC-DOS) · Take the voyage to another machine
In BASIC Quick Reference, open Browse and mount Hello Disk.
See also DRIVE, DIR — SDC-DOS, DRIVE NEW.
DSKI$
Read a disk sector into two string variables.
DSKI$ drive,track,sector,string1,string2
The strings receive the two halves of a 256-byte sector.
Raw-sector access bypasses normal file interpretation.
Disk BASIC · Take the voyage to another machine
See also DSKO$.
DSKINI
Initialize a disk for BASIC file storage.
DSKINI [drive]
Select the intended drive explicitly.
Erases the selected disk and disturbs BASIC workspace. Use only a blank disposable image.
Disk BASIC · Take the voyage to another machine
DSKO$
Write two strings directly to a disk sector.
DSKO$ drive,track,sector,string1,string2
Use properly sized data for the selected sector.
Raw writes can corrupt the filesystem. This is not a safe way to save a BASIC program.
Disk BASIC · Take the voyage to another machine
See also DSKI$.
E
EDIT
Use the original BASIC line editor for one program line.
EDIT line
The native BASIC editor is a separate way to edit source.
CoCo 3 BASIC · Make the CoCo answer
ELSE
Introduce the false branch of an IF statement.
IF condition THEN statements ELSE statements
CoCo 3 BASIC · Choose a destination
END
Finish the program.
END
CoCo 3 BASIC · Make the CoCo answer
In BASIC Quick Reference, open Hello, CoCo.
EOF
Check whether an open input stream is at end of file.
EOF(file)
0 means more input remains; -1 indicates end of file.
Also applies to cassette input with device -1.
Disk BASIC · Keep a log past bedtime
See also OPEN, INPUT — disk file.
ERLIN
Read the BASIC line number that caused the trapped error.
ERLIN
Use inside an ON ERR handler.
CoCo 3 BASIC · Find the missing supply
In BASIC Quick Reference, open Handle an error.
ERNO
Read the numeric code for the last trapped BASIC error.
ERNO
Use inside an ON ERR handler.
CoCo 3 BASIC · Find the missing supply
In BASIC Quick Reference, open Handle an error.
ERR
Introduce an error trap as part of ON ERR GOTO.
ON ERR GOTO line
CoCo 3 BASIC · Find the missing supply
EXEC
Transfer execution to a machine-language entry point.
EXEC [address]
Without an address, use the entry point from the last applicable machine-language load.
Running arbitrary memory as code can crash or alter the emulated machine.
CoCo 3 BASIC · Where BASIC meets the machine
EXP
Raise e to a numeric power.
EXP(number)
Large arguments can overflow.
CoCo 3 BASIC · Count the supplies
F
FIELD
Divide a direct-access buffer into string fields.
FIELD #file,length AS stringVariable[, ...]
Field lengths must fit in the opened record.
Use LSET/RSET rather than ordinary string assignment when filling fields.
Disk BASIC · Keep a log past bedtime
See also OPEN, LSET, RSET, GET — disk record, PUT — disk record.
FILES
Allocate file buffers for disk access.
FILES count[,size]
count reserves file buffers; size supplies the total buffer size.
Changes BASIC workspace allocation. Arrange file buffers before storing working data.
Disk BASIC · Keep a log past bedtime
FIX
Remove the fractional part toward zero.
FIX(number)
FIX(-2.7) is -2.
CoCo 3 BASIC · Count the supplies
In BASIC Quick Reference, open Numbers and rounding.
See also INT.
FN
Invoke a function defined with DEF FN.
FNname(argument)
CoCo 3 BASIC · Give a routine a job
See also DEF FN.
FOR
Start a counted loop.
FOR variable = start TO finish [STEP increment]
increment defaults to 1; a negative value counts downward.
NEXT closes the loop.
CoCo 3 BASIC · Count the supplies
In BASIC Quick Reference, open A counting loop.
FREE
Count free granules on a BASIC disk.
FREE(drive)
Granules are the BASIC filesystem's allocation units.
Disk BASIC · Take the voyage to another machine
See also DIR.
G
GET · GET — disk record · GO · GOSUB · GOTO
GET
Copy a PMODE rectangle into a numeric array.
GET(x1,y1)-(x2,y2),array[,G]
Dimension a two-dimensional array large enough for the rectangle.
G stores full graphics detail for PUT operations.
GET #file,record is a different form for disk files.
CoCo 3 BASIC · Draw a planet you can find again
See also PUT, GET — disk record.
GET — disk record
Read a direct-access record into its file buffer.
GET #file[,record]
Use OPEN "D" and FIELD to interpret the record.
An omitted record advances through the file.
This form is separate from graphics GET.
Disk BASIC · Keep a log past bedtime
See also FIELD, PUT — disk record, GET.
GO
Prefix of GO TO and GO SUB; the joined forms are also accepted.
GO TO line
GO SUB line
CoCo 3 BASIC · Choose a destination
GOSUB
Call a numbered subroutine and remember where to return.
GOSUB line
End the subroutine with RETURN.
Use the editor's Step Into, Step Over or Step Out to follow calls.
CoCo 3 BASIC · Give a routine a job
In BASIC Quick Reference, open A returning subroutine.
GOTO
Continue execution at another numbered line.
GOTO line
line must exist in the loaded program.
CoCo 3 BASIC · Choose a destination
In BASIC Quick Reference, open Choose a branch.
See also GOSUB, ON, UL — Undefined line.
H
HBUFF · HCIRCLE · HCLS · HCOLOR · HDRAW · HEX$ · HGET · HLINE · HPAINT · HPOINT · HPRINT · HPUT · HRESET · HSCREEN · HSET · HSTAT
HBUFF
Reserve a buffer for high-resolution GET/PUT graphics.
HBUFF buffer,size
size is the number of bytes to reserve; maximum 7931.
CoCo 3 BASIC · Draw a planet you can find again
HCIRCLE
Draw a high-resolution circle, ellipse or arc.
HCIRCLE(x,y),radius[,color[,ratio[,start,end]]]
Optional ratio changes the shape; start/end restrict the arc.
CoCo 3 BASIC · Draw a planet you can find again
HCLS
Fill the CoCo 3 high-resolution graphics screen.
HCLS [color]
Omitting color uses the current background.
CoCo 3 BASIC · Draw a planet you can find again
In BASIC Quick Reference, open CoCo 3 graphics.
HCOLOR
Choose foreground and background palette entries for high-resolution graphics.
HCOLOR foreground,background
Use palette entries available in the selected HSCREEN mode.
CoCo 3 BASIC · Draw a planet you can find again
HDRAW
Use a movement string to draw high-resolution graphics.
HDRAW string
Uses the movement commands described under DRAW.
CoCo 3 BASIC · Draw a planet you can find again
HEX$
Convert a number to hexadecimal text.
HEX$(number)
The returned string has no &H prefix.
CoCo 3 BASIC · Give a chart its names
HGET
Save a high-resolution rectangle in an HBUFF buffer.
HGET(x1,y1)-(x2,y2),buffer
Reserve sufficient space with HBUFF before copying.
CoCo 3 BASIC · Draw a planet you can find again
HLINE
Draw a high-resolution line or rectangle.
HLINE [(x1,y1)]-(x2,y2),color[,B or BF]
B draws a box; BF fills it.
color may be a palette entry, PSET or PRESET.
CoCo 3 BASIC · Draw a planet you can find again
HPAINT
Fill a bounded high-resolution region.
HPAINT(x,y)[,color[,border]]
Select a point inside a closed border.
CoCo 3 BASIC · Draw a planet you can find again
HPOINT
Read the color of a high-resolution graphics point.
HPOINT(x,y)
Coordinates follow the selected HSCREEN mode.
CoCo 3 BASIC · Draw a planet you can find again
In BASIC Quick Reference, open CoCo 3 graphics.
See also HSET.
HPRINT
Draw text in a CoCo 3 high-resolution graphics display.
HPRINT(column,row),string
Coordinates select character cells, not individual pixels.
CoCo 3 BASIC · Draw a planet you can find again
HPUT
Restore a high-resolution rectangle from a buffer.
HPUT(x1,y1)-(x2,y2),buffer,action
action: PSET, PRESET, AND, OR or NOT.
CoCo 3 BASIC · Draw a planet you can find again
HRESET
Reset a high-resolution point to the background.
HRESET(x,y)
CoCo 3 BASIC · Draw a planet you can find again
HSCREEN
Select a CoCo 3 high-resolution graphics display.
HSCREEN mode
0: return to low-resolution display.
1: 320x192, 4 colors; 2: 320x192, 16 colors.
3: 640x192, 2 colors; 4: 640x192, 4 colors.
Selecting modes 1-4 also clears that graphics display.
CoCo 3 BASIC · Draw a planet you can find again
In BASIC Quick Reference, open CoCo 3 graphics.
HSET
Set a point in CoCo 3 high-resolution graphics.
HSET(x,y[,color])
Omitting color uses the foreground.
Coordinates depend on the HSCREEN resolution.
CoCo 3 BASIC · Draw a planet you can find again
In BASIC Quick Reference, open CoCo 3 graphics.
HSTAT
Read the high-resolution text character, attributes and cursor coordinates.
HSTAT character,attribute,column,row
Supply numeric variables to receive the four results.
CoCo 3 BASIC · Design a flight deck
I
IF
Choose statements or a destination line according to a test.
IF condition THEN statements [ELSE statements]
IF condition THEN line [ELSE line]
Zero is false; a nonzero value is true.
A false condition skips the remainder of its branch on that BASIC line.
CoCo 3 BASIC · Choose a destination
In BASIC Quick Reference, open Choose a branch.
INKEY$
Read a waiting key without stopping for input.
INKEY$
The result is an empty string when no key is waiting.
CoCo 3 BASIC · Listen for a signal
INPUT
Read keyboard values into numeric or string variables.
INPUT ["prompt";] variable [, variable ...]
Separate multiple responses with commas.
Use LINE INPUT when a whole line, including commas, belongs in one string.
CoCo 3 BASIC · Choose a destination
See also LINE INPUT, INKEY$.
INPUT — disk file
Read delimited values from an open input file.
INPUT #file,variable[,variable ...]
Variable types must match the stored fields.
Disk BASIC · Keep a log past bedtime
INSTR
Find the first occurrence of a substring.
INSTR([start,]string,target)
Positions start at 1; a zero result means no match.
CoCo 3 BASIC · Give a chart its names
In BASIC Quick Reference, open Working with strings.
INT
Round down to an integer, including for negative values.
INT(number)
INT(-2.7) is -3.
CoCo 3 BASIC · Count the supplies
In BASIC Quick Reference, open Numbers and rounding.
See also FIX.
J
JOYSTK
Read an emulated joystick axis.
JOYSTK(axis)
0: right X; 1: right Y; 2: left X; 3: left Y.
Values range from 0 to 63; center is about 31.
CoCo 3 BASIC · Listen for a signal
See also BUTTON.
K
KILL
Remove a file from a BASIC disk directory.
KILL "filename/ext[:drive]"
Include the extension.
Deletes the file from the selected disk; the command has no Undo.
Disk BASIC · Take the voyage to another machine
L
LEFT$ · LEN · LET · LINE · LINE INPUT · LINE INPUT — disk file · LIST · LLIST · LOAD · LOADM · LOC · LOCATE · LOF · LOG · LPEEK · LPOKE · LSET
LEFT$
Take characters from the beginning of a string.
LEFT$(string,count)
count is the maximum number of characters returned.
CoCo 3 BASIC · Give a chart its names
In BASIC Quick Reference, open Working with strings.
LEN
Count the characters in a string.
LEN(string)
CoCo 3 BASIC · Give a chart its names
In BASIC Quick Reference, open Working with strings.
LET
Assign a value to a variable; LET is optional.
[LET] variable = expression
Use a name ending in $ for a string.
Only the first two characters of a variable name distinguish it in this BASIC.
Changing source in the editor does not change variables in a running CoCo program.
CoCo 3 BASIC · Choose a destination
In BASIC Quick Reference, open Numbers and rounding.
See also DIM.
LINE
Draw a PMODE line, rectangle or filled rectangle.
LINE [(x1,y1)]-(x2,y2),action[,B or BF]
action is PSET or PRESET; B draws a rectangle and BF fills it.
If the first point is omitted, drawing starts at the previous endpoint.
B or BF can be used with either PSET or PRESET.
CoCo 3 BASIC · Draw a planet you can find again
LINE INPUT
Read an entire line into a string variable.
LINE INPUT ["prompt";] stringVariable
Commas in the entered line remain part of the string.
CoCo 3 BASIC · Choose a destination
See also INPUT, LINE INPUT — disk file.
LINE INPUT — disk file
Read an entire file line into one string.
LINE INPUT #file,stringVariable
Commas remain part of the string.
Disk BASIC · Keep a log past bedtime
See also OPEN, EOF, LINE INPUT.
LIST
Display a program or a range of BASIC lines.
LIST [first[-last]]
LIST -last
LIST first-
A single line number lists only that line.
Read from CoCo brings program text into the native editor without typing LIST.
CoCo 3 BASIC · Make the CoCo answer
LLIST
Send a program listing to the printer device.
LLIST [first[-last]]
Enable VCC Plus Printer Output capture to collect printer text.
CoCo 3 BASIC · Design a flight deck
LOAD
Load a BASIC program from disk.
LOAD "filename"[,R]
R runs the program after loading.
A :drive suffix selects a drive instead of the default.
Loading replaces the BASIC program in CoCo memory.
Disk BASIC · Take the voyage to another machine
See also SAVE, RUN — disk file.
LOADM
Load a machine-language file from disk.
LOADM "filename"[,offset]
offset changes where bytes are loaded; internal machine-code addresses are not relocated.
Use EXEC after loading unless the file implements its own autostart.
Disk BASIC · Take the voyage to another machine
LOC
Read the current record number for an open disk file.
LOC(file)
file refers to an open disk buffer.
Disk BASIC · Keep a log past bedtime
LOCATE
Position the cursor in the CoCo 3 high-resolution text screen.
LOCATE column,row
Coordinates start at zero.
Use WIDTH 40 or WIDTH 80 first.
CoCo 3 BASIC · Design a flight deck
LOF
Read the highest record number in an open disk file.
LOF(file)
This is a record count, not a Mac file-size query.
Disk BASIC · Keep a log past bedtime
LOG
Return the natural logarithm.
LOG(number)
number must be positive.
CoCo 3 BASIC · Count the supplies
LPEEK
Read a byte using the CoCo 3 long-memory interface.
LPEEK(address)
address: 0-524287. This BASIC interface is limited to 512 KB.
CoCo 3 BASIC · Where BASIC meets the machine
See also LPOKE.
LPOKE
Write a byte using the CoCo 3 BASIC long-memory interface.
LPOKE address,value
address: 0-524287; value: 0-255.
This command's address range does not expand simply because the emulator has more RAM.
CoCo 3 BASIC · Where BASIC meets the machine
LSET
Left-align text in a direct-access field.
LSET stringField = string
Short strings are padded; long strings are limited to the field length.
Disk BASIC · Keep a log past bedtime
M
MEM
Report currently free BASIC memory.
MEM
Available BASIC workspace is not the same as the selected total machine RAM.
CoCo 3 BASIC · Where BASIC meets the machine
MERGE
Combine a disk ASCII listing with the program in memory.
MERGE "filename"[,R]
Save the source file with SAVE ...,A first.
R starts the merged program.
Duplicate line numbers are replaced by the incoming lines.
Disk BASIC · Take the voyage to another machine
MID$
Read a substring, or replace characters in a string variable.
MID$(string,start[,count])
MID$(stringVariable,start[,count]) = replacement
Positions start at 1.
Without count, the function reads to the end.
Assignment changes existing characters; it does not insert new space.
CoCo 3 BASIC · Give a chart its names
In BASIC Quick Reference, open Working with strings.
MKN$
Encode a BASIC number into its five-byte representation.
MKN$(number)
Use with fixed-length binary fields; this is not decimal text.
Disk BASIC · Keep a log past bedtime
MOTOR
Control the cassette motor signal.
MOTOR ON
MOTOR OFF
CoCo 3 BASIC · Take the voyage to another machine
N
NEW
Erase the program currently held by BASIC.
NEW
This changes CoCo memory, not a saved Mac source file.
CoCo 3 BASIC · Make the CoCo answer
NEXT
Advance a FOR loop and test whether it should repeat.
NEXT [variable [, variable ...]]
For nested loops, close the innermost loop first.
CoCo 3 BASIC · Count the supplies
In BASIC Quick Reference, open A counting loop.
See also FOR, NF — NEXT without FOR.
NOT
Invert an integer bit pattern or a BASIC truth value.
NOT expression
CoCo 3 BASIC · Choose a destination
O
OFF
Disable a feature in commands that accept an ON/OFF switch.
AUDIO OFF
MOTOR OFF
VERIFY OFF
CoCo 3 BASIC · Listen for a signal
ON
Select a GOTO or GOSUB destination by its position in a list.
ON expression GOTO line [, line ...]
ON expression GOSUB line [, line ...]
A value of 1 selects the first destination.
Zero or a value beyond the list falls through.
CoCo 3 BASIC · Give a routine a job
In BASIC Quick Reference, open Choose a branch.
ON BRK
Branch to a handler when the CoCo Break key is pressed.
ON BRK GOTO line
CoCo 3 extension.
ON BRK GOTO 0 restores ordinary Break handling.
CoCo 3 BASIC · Find the missing supply
ON ERR
Send runtime errors to a BASIC handler on the CoCo 3.
ON ERR GOTO line
Use ERNO and ERLIN in the handler to identify the error.
ON ERR GOTO 0 disables the handler.
Handled errors remain under BASIC control; VCC Plus does not replace them with its unhandled-error pause.
CoCo 3 BASIC · Find the missing supply
In BASIC Quick Reference, open Handle an error.
See also ERNO, ERLIN, SN — Syntax error.
OPEN
Open a data stream to a file or device.
OPEN "mode",#file,"filename"[,recordLength]
I reads sequential data; O writes sequential data; D selects direct-access disk records.
Disk file numbers: 1-15, subject to FILES allocation.
Device -1 is cassette; -2 is printer; 0 is console.
O can replace an existing file; use a disposable output filename while learning.
Disk BASIC · Keep a log past bedtime
OR
Combine conditions or integer bit patterns when either side is set.
expression OR expression
CoCo 3 BASIC · Choose a destination
P
PAINT · PALETTE · PCLEAR · PCLS · PCOPY · PEEK · PLAY · PMODE · POINT · POKE · POS · PPOINT · PRESET · PRINT · PRINT USING · PRINT — file or printer · PRINT@ · PSET · PUT · PUT — disk record
PAINT
Fill a bounded PMODE area from a starting point.
PAINT(x,y)[,color[,border]]
The starting point must be inside a closed border for a bounded fill.
CoCo 3 BASIC · Draw a planet you can find again
PALETTE
Assign a CoCo 3 palette entry or restore a standard palette.
PALETTE register,color
PALETTE CMP
PALETTE RGB
register: 0-15; color: 0-63.
CMP and RGB choose standard tables for the corresponding monitor signal.
The BASIC palette and VCC Plus Video Signal setting are related but separate controls.
CoCo 3 BASIC · Draw a planet you can find again
PCLEAR
Reserve 1.5 KB pages for PMODE graphics.
PCLEAR pages
Reserve enough pages for the chosen PMODE and starting page.
CoCo 3 BASIC · Draw a planet you can find again
In BASIC Quick Reference, open Draw and inspect a point.
PCLS
Fill the current PMODE graphics screen.
PCLS [color]
Omitting color uses the current background.
CoCo 3 BASIC · Draw a planet you can find again
In BASIC Quick Reference, open Draw and inspect a point.
PCOPY
Copy one reserved PMODE graphics page to another.
PCOPY source TO destination
Pages must have been reserved with PCLEAR.
CoCo 3 BASIC · Draw a planet you can find again
PEEK
Read a byte through the current CPU memory map.
PEEK(address)
address: 0-65535.
Reading device registers can affect the device.
CoCo 3 BASIC · Where BASIC meets the machine
See also POKE.
PLAY
Play notes described by a music string.
PLAY string
A-G name notes; O selects octave, L note length and T tempo.
# or + sharpens a note; - flattens it; P inserts a pause.
CoCo 3 BASIC · Listen for a signal
See also SOUND.
PMODE
Choose the resolution and starting page for traditional CoCo graphics.
PMODE mode,page
0: 128x96, 2 colors; 1: 128x96, 4 colors.
2: 128x192, 2 colors; 3: 128x192, 4 colors.
4: 256x192, 2 colors.
CoCo 3 BASIC · Draw a planet you can find again
In BASIC Quick Reference, open Draw and inspect a point.
POINT
Read a semigraphics block on the text screen.
POINT(x,y)
-1 indicates part of an ordinary text character; otherwise the result describes the block color.
CoCo 3 BASIC · Draw a planet you can find again
See also SET.
POKE
Write one byte through the current CPU memory map.
POKE address,value
address: 0-65535; value: 0-255.
Writes can change programs, device registers or system state. Use only addresses you understand.
CoCo 3 BASIC · Where BASIC meets the machine
POS
Read the current print-column position for a device.
POS(device)
device 0 is the screen; -2 is the printer.
CoCo 3 BASIC · Design a flight deck
PPOINT
Read the color of a PMODE graphics point.
PPOINT(x,y)
CoCo 3 BASIC · Draw a planet you can find again
In BASIC Quick Reference, open Draw and inspect a point.
See also PSET.
PRESET
Reset a PMODE point to the background color.
PRESET(x,y)
CoCo 3 BASIC · Draw a planet you can find again
Display values on the text screen.
PRINT [expression [; or , expression] ...]
Semicolon joins output without a print-zone advance.
Comma advances to the next print zone.
A trailing separator suppresses the usual newline.
? is a shorthand for PRINT.
CoCo 3 BASIC · Make the CoCo answer
In BASIC Quick Reference, open Hello, CoCo.
PRINT USING
Print values with a reusable layout.
PRINT USING "format";expression[;expression ...]
Each # reserves a digit position; a decimal point places the fractional part.
For strings, ! prints one character and % followed by spaces and % defines a fixed-width field.
CoCo 3 BASIC · Design a flight deck
In BASIC Quick Reference, open Formatted output.
PRINT — file or printer
Write formatted values to an open file or output device.
PRINT #file,expression[; or , expression ...]
-2 selects the printer; -1 selects cassette.
Positive file numbers refer to previously opened disk files.
Disk/cassette output writes media. Printer text is captured only when the VCC Plus printer is enabled.
Disk BASIC · Keep a log past bedtime
PRINT@
Place text at a numbered position on the 32-column screen.
PRINT @position, expression
position: 0-511, counted across rows from the top left.
CoCo 3 BASIC · Design a flight deck
PSET
Set a point in the PMODE drawing area.
PSET(x,y[,color])
Drawing coordinates use x: 0-255 and y: 0-191.
Omit color to use the current foreground.
CoCo 3 BASIC · Draw a planet you can find again
In BASIC Quick Reference, open Draw and inspect a point.
PUT
Draw a PMODE rectangle from a saved numeric array.
PUT(x1,y1)-(x2,y2),array[,action]
action: PSET, PRESET, AND, OR or NOT.
Use a matching rectangle and storage prepared by GET.
CoCo 3 BASIC · Draw a planet you can find again
See also GET, PUT — disk record.
PUT — disk record
Write the file buffer as a direct-access record.
PUT #file[,record]
Use LSET/RSET to fill the buffer before writing.
This changes the opened disk file. It is separate from graphics PUT.
Disk BASIC · Keep a log past bedtime
See also FIELD, GET — disk record, PUT.
R
READ · REM · RENAME · RENUM · RESET · RESTORE · RETURN · RGB · RIGHT$ · RND · RSET · RUN · RUN — disk file · RUNM
READ
Take the next values from the program's DATA statements.
READ variable [, variable ...]
Variable type must match the corresponding value.
CoCo 3 BASIC · Give a chart its names
In BASIC Quick Reference, open Read a small data table.
See also DATA, RESTORE, OD — Out of DATA.
REM
Add a comment that BASIC does not execute.
REM comment
An apostrophe also starts a comment. Quoted strings and comments retain their entered case.
CoCo 3 BASIC · Make the CoCo answer
See also DATA.
RENAME
Change a filename within the same BASIC disk.
RENAME "old/ext[:drive]" TO "new/ext[:drive]"
Include both extensions.
Changes the disk directory.
Disk BASIC · Take the voyage to another machine
RENUM
Renumber program lines and update recognized line references.
RENUM [newStart [, oldStart [, increment]]]
newStart is the first assigned number.
oldStart selects the first old line to change.
increment controls spacing.
The editor Renumber action supports Undo and updates editor source rather than the current CoCo program.
CoCo 3 BASIC · Find the missing supply
See also LIST.
RESET
Clear a semigraphics block on the text screen.
RESET(x,y)
x: 0-63; y: 0-31.
CoCo 3 BASIC · Draw a planet you can find again
RESTORE
Move the DATA pointer back to the first item.
RESTORE
CoCo 3 BASIC · Give a chart its names
In BASIC Quick Reference, open Read a small data table.
RETURN
Resume immediately after the matching GOSUB call.
RETURN
RETURN needs an active GOSUB call.
CoCo 3 BASIC · Give a routine a job
In BASIC Quick Reference, open A returning subroutine.
See also GOSUB, RG — RETURN without GOSUB.
RGB
Restore the standard RGB palette on a CoCo 3.
PALETTE RGB
CoCo 3 BASIC · Draw a planet you can find again
RIGHT$
Take characters from the end of a string.
RIGHT$(string,count)
count is the maximum number of characters returned.
CoCo 3 BASIC · Give a chart its names
In BASIC Quick Reference, open Working with strings.
RND
Generate a pseudo-random value.
RND(limit)
RND(0) returns a fractional value.
A positive integer limit returns an integer from 1 through limit.
CoCo 3 BASIC · Count the supplies
RSET
Right-align text in a direct-access field.
RSET stringField = string
Short strings are padded on the left.
Disk BASIC · Keep a log past bedtime
RUN
Start the program in memory, normally clearing its variables.
RUN [line]
Omit line to start at the beginning.
Use the editor's Run button to transfer edited source and start it.
CoCo 3 BASIC · Make the CoCo answer
In BASIC Quick Reference, open Hello, CoCo.
See also END, RUN — disk file.
RUN — disk file
Load and run a BASIC program from disk.
RUN "filename"[,R]
R preserves open files while chaining to the new program.
Replaces the in-memory BASIC program.
Disk BASIC · Take the voyage to another machine
RUNM
Load and execute a machine-language program in one command.
RUNM "filename[:drive]"
For binaries that start themselves during loading, use LOADM instead; RUNM can execute their entry point again.
Hard Drive BASIC (RGB-DOS) · Take the voyage to another machine
S
SAVE · SAVEM · SCREEN · SET · SGN · SIN · SKIPF · SOUND · SQR · STEP · STOP · STR$ · STRING$ · SUB
SAVE
Write the in-memory BASIC program to disk.
SAVE "filename"[,A]
A selects an ASCII listing instead of tokenized storage.
Writes to the selected image and may replace an existing file. The native editor Save command instead saves a Mac source file.
Disk BASIC · Take the voyage to another machine
SAVEM
Write a memory range as a machine-language disk file.
SAVEM "filename",first,last,entry
first/last are inclusive addresses; entry is the default EXEC address.
Writes to the selected disk image.
Disk BASIC · Take the voyage to another machine
SCREEN
Switch between the traditional text and graphics displays.
SCREEN type,colorSet
type: 0 for text, 1 for PMODE graphics.
colorSet: 0 or 1.
CoCo 3 BASIC · Draw a planet you can find again
In BASIC Quick Reference, open Draw and inspect a point.
SET
Color one semigraphics block on the 32-column text screen.
SET(x,y,color)
x: 0-63; y: 0-31; color: 0-8.
CoCo 3 BASIC · Draw a planet you can find again
SGN
Return -1, 0 or 1 for a negative, zero or positive number.
SGN(number)
CoCo 3 BASIC · Count the supplies
In BASIC Quick Reference, open Numbers and rounding.
SIN
Return the sine of an angle in radians.
SIN(angle)
A full turn is 2*PI radians; use a numeric value for PI.
CoCo 3 BASIC · Count the supplies
SKIPF
Advance through a cassette file without loading it.
SKIPF ["filename"]
CoCo 3 BASIC · Take the voyage to another machine
SOUND
Play a tone for a specified duration.
SOUND pitch,duration
pitch: 1-255; duration: 1-255.
CoCo 3 BASIC · Listen for a signal
SQR
Return the nonnegative square root.
SQR(number)
number must be zero or positive.
CoCo 3 BASIC · Count the supplies
In BASIC Quick Reference, open Numbers and rounding.
STEP
Set the increment of a FOR loop.
FOR variable=start TO finish STEP increment
CoCo 3 BASIC · Count the supplies
STOP
Stop execution and report the BASIC line.
STOP
A BASIC STOP is distinct from an editor breakpoint.
CoCo 3 BASIC · Find the missing supply
STR$
Convert a number into a printable string.
STR$(number)
Positive numbers normally include a leading space.
CoCo 3 BASIC · Give a chart its names
In BASIC Quick Reference, open Working with strings.
STRING$
Create a string containing a repeated character.
STRING$(count,codeOrString)
A string argument supplies its first character.
CoCo 3 BASIC · Give a chart its names
In BASIC Quick Reference, open Formatted output.
SUB
Complete the split spelling GO SUB.
GO SUB line
CoCo 3 BASIC · Give a routine a job
T
TAB
Advance within a PRINT line to a column.
PRINT TAB(column);expression
CoCo 3 BASIC · Design a flight deck
TAN
Return the tangent of an angle in radians.
TAN(angle)
Angles near odd multiples of PI/2 produce very large results.
CoCo 3 BASIC · Count the supplies
THEN
Introduce the true branch of an IF statement.
IF condition THEN statements
CoCo 3 BASIC · Choose a destination
TIMER
Read or set the interpreter's ticking counter.
TIMER
TIMER = value
The counter wraps at 65536.
It advances with the emulated machine, not a guaranteed wall-clock duration.
CoCo 3 BASIC · Listen for a signal
TO
Separate start/end values or source/destination operands.
FOR variable=start TO finish
CoCo 3 BASIC · Count the supplies
TROFF
Turn off the BASIC line-number trace.
TROFF
CoCo 3 BASIC · Find the missing supply
See also TRON.
TRON
Show BASIC line numbers as the program executes.
TRON
This is the interpreter's text trace; it is independent of editor breakpoints.
CoCo 3 BASIC · Find the missing supply
See also TROFF.
U
UNLOAD
Close open files associated with a disk.
UNLOAD [drive]
Omitting drive selects the default drive.
This BASIC command does not eject the Mac disk-image file from VCC Plus.
Disk BASIC · Take the voyage to another machine
See also CLOSE, DRIVE — SDC-DOS.
USING
Apply a numeric or string layout to printed values.
PRINT USING "format";expression
CoCo 3 BASIC · Design a flight deck
In BASIC Quick Reference, open Formatted output.
See also PRINT, PRINT — file or printer.
USR
Call a machine-language function defined with DEF USR.
USRn(argument)
n: 0-9. Define a valid entry address and calling convention first.
CoCo 3 BASIC · Where BASIC meets the machine
See also DEF USR.
V
VAL
Convert a numeric prefix of a string into a number.
VAL(string)
Parsing follows BASIC numeric notation.
CoCo 3 BASIC · Give a chart its names
In BASIC Quick Reference, open Working with strings.
VARPTR
Find the address of a variable's internal storage.
VARPTR(variable)
BASIC may move storage later; do not assume the address remains valid.
CoCo 3 BASIC · Where BASIC meets the machine
VERIFY
Choose whether disk writes are followed by a verification read.
VERIFY ON
VERIFY OFF
Verification checks the data written to the emulated disk.
This is an interpreter setting, not the image's write-protection setting.
Disk BASIC · Take the voyage to another machine
See also SAVE.
W
WIDTH
Select the CoCo 3 text-screen width.
WIDTH columns
columns: 32, 40 or 80.
40- and 80-column modes have 24 rows.
CoCo 3 extension.
CoCo 3 BASIC · Design a flight deck
WRITE
Write comma-delimited data suitable for INPUT.
WRITE #file,expression[,expression ...]
String values are quoted automatically.
Writes to the opened output file.
Disk BASIC · Keep a log past bedtime
See also OPEN, INPUT, INPUT — disk file.