
BASIC Quick Reference
=====================

System Commands
===============


CLOAD
 -- to load a program into memory from cassette tape.
 CLOAD "filename"
 CLOAD "PROG1"
 CLOAD


CLOAD?
 -- To compare the program in memory with a program on cassette tape.
 CLOAD? "filename"
 CLOAD? "PROG2"


CONT
 -- To continue program execution after a STOP has occurred.
 CONT


CSAVE
 -- To save a program on cassette tape.
 CSAVE "filename"
 CSAVE "PROG1"


LCOPY
 -- to output the information on the screen to the PC-6021(A) Thermal Printer.
 LCOPY


LIST/LLIST
 -- To display (LIST) or print (LLIST) a program or portion of a program to the CRT screen or the line printer.
 LIST [starting line number] [-ending line number]
 LLIST [starting line number] [-ending line number]
 LIST 100-200


NEW
 -- To clear all variables and erase any program in memory.
 NEW


RUN
 -- To execute a program in memory.
 RUN [line number]
 RUN
 RUN 100



Statements
==========


CLEAR
 -- To reset all variables to 0 or null, establish the size of string space, and to set the top end of memory.
 CLEAR [m],N
 CLEAR 300, &HD000
 CLEAR 0


CLS
 -- To clear the screen.
 CLS


COLOR
 -- To set colors for the screen display
 COLOR [f] [,b] [,c]
 COLOR 2,1,1


CONSOLE
 -- To define the range of scroll and define the on/off state of function keys and key click.
 CONSOLE L, N, K, C
 CONSOLE 0, 25, 0, 1


CSRLIN
 -- To return the current line number of the cursor.
 PRINT CSRLIN
 A=CSRLIN


DATA
 -- To store numeric and/or string constants within a program.
 DATA constant [,constant]...
 DATA 123, abc


DEF FN
 -- To specify a user-defined mathematical or logical function.
 DEFFN name(argument) = functional expression
 DEF FNA(X)=X*2


DIM
 -- To set the limits of an array.
 DIM variable(size) [,variable(size)]...
 DIM A(20)


END
 -- To terminate program execution.
 END


EXEC
 -- To execute a machine language program starting at a specific address.
 EXEC address
 EXEC &HD000


EXP
 -- To compute the natural logarithm's base e raised to a specified power.
 X=EXP(Y)
 PRINT EXP(.05)


FOR/NEXT
 -- To execute a sequence of statements a given number of times.
 FOR variable=expression TO expression [STEP expression] : NEXT variable
 FOR J=0 TO 100 STEP 2
 NEXT J


GOSUB/RETURN
 -- To transfer control temporarily to a subroutine starting at a specified line number.  The RETURN statement is required to return to the main program logic.
 GOSUB line number
 GOSUB 1000


GOTO
 -- To transfer control to a specified line number
 GOTO line number
 GOTO 1000


IF ... THEN
 -- To evaluate an expression and process certain statements based on the result of the evaluation.
 IF expression THEN statement or line number
 IF A$="Y" THEN 200
 IF A$="X" GOSUB 300


INPUT
 -- To request an operator response and store the result in a variable.
 INPUT ["prompt string";] variable [,variable]...
 INPUT "Date"; A$


INPUT#
 -- To request an operator response through different input devices.
 INPUT# -device number, variable [,variable]...
 INPUT# -0,A$


KEY
 -- To change information assigned to the function keys.
 KEY number, "name"
 KEY 1,"LINE"


KILL   [E]
 -- Used to delete a file on disk.
 KILL "[drive#:]filename"
 KILL "2:myprog"


LET
 -- To assigna value to a variable (optional).
 LET variable=expression
 LET A$="BASIC"


LINE
 -- To draw a line in a specified color between two positions or a box with the diagonal end points given
 LINE (x1,y1)-(x2,y2) [,color] [,B[F]]
 LINE (10,10)-(90,90),2


LOCATE
 -- To move the cursor to a specified character location
 LOCATE horizontal position, vertical position
 LOCATE 24,3


LPRINT
 -- To output data to a printer
 LPRINT expression[,expression]...
 LPRINT A$,"ABC"

ON ... GOSUB
 -- To branch to one of several subroutines determined by the value of an expression.
 ON expression GOSUB line number [,line number]...
 ON A GOSUB 100, 200, 300


ON ... GOTO
 -- To branch to one of several line numbers based on the evaluation of an expression.
 ON expression GOTO line number, [line number]...
 ON B GOTO 300, 99, 400, 650


OUT
 -- To output data to a specified port such as an RS-232C or joystick
 OUT portnumber, data
 OUT &HB0, &F3


PAINT
 -- To establish or change the color of a specified area on the screen.
 PAINT (x,y) [,color [,boundary color]]
 PAINT (20,20),3,2


PLAY
 -- To generate a musical tone
 PLAY voice_A string [,voice_B string] [,voice_C string]
 PLAY "A+ O3 R1 G B-"

POINT
 -- To determine the color of a point at the coordinate (x,y).
 POINT (x,y)
 A=POINT(10,10)


PRESET
 -- To delete the dot displayed at the coordinate (x,y).
 PRESET(x,y)
 PRESET(20,30)


PRINT
 -- To display data on the CRT screen.
 PRINT expression [;experession]...
 PRINT "A=";A


PRINT#
 -- To output data to a specified output device.
 PRINT# -devicenumber, expression [,expression]...
 PRINT# -1,"ABC"


PSET
 -- To display a dot at the coordinate position (x,y) in a specified color.
 PSET (x,y) [,color]
 PSET (10,10),2


READ
 -- To read data stored in a data statement and assign it to a variable name.
 READ variable [,variable]...
 READ D$,A


REM
 -- To write remarks or comments in a program.
 REM comments
 REM ** input routine follows **


RESTORE
 -- To reset BASIC's internal pointer so that data in DATA statements can be reused.
 RESTORE [line number]
 RESTORE 5000


RETURN
 -- To return control to the main program at the end of a subroutine execution.
 RETURN


SCREEN
 -- To change the display mode of the screen.
 SCREEN m,d,w
 SCREEN 2,1,1


STEP 
 -- To define an increment with the FOR/NEXT statements.
 STEP increment
 FOR J=1 TO 10 STEP 2:NEXT J


STOP
 -- To interrupt program execution
 STOP


SOUND
 -- To generate sounds and noises
 SOUND registernumber, data
 SOUND 0,255


TIME
 -- To enable a timing mechanism
 TIME
 X=TIME


USR
 -- To execute machine language code in memory.  Pointer to machine language code must be stored at &HFAEB/&HFAEC.



Functions
=========


ABS
 -- Returns the absolute value of a number.
 ABS(x)
 A=ABS(-3)


ASC
 -- Returns the ASCII value of a given character.
 ASC(x$)
 A=ASC("A")


CHR$
 -- Returns a character whose ASCII code is x.
 CHR$(x)
 A$=CHR$(65)


COS
 -- Returns the cosine of x radians.
 COS(x)
 C=COS(3.1415/2)


EXP
 -- To compute the natural logarithm's base e raised to a specified power.
 X=EXP(Y)
 PRINT EXP(.05)


FRE
 -- To return the number of bytes remaining in memory or string space.
 FRE(x)
 FRE(x$)
 PRINT FRE(A), FRE(A$)


INKEY$
 -- To check the keyboard to see if any keys were pressed.
 INKEY$
 A$=INKEY$


INP
 -- To read data through an I/O port at a specified I/O address.
 INP(x)
 PRINT INP(&H90)


INT
 -- To round off (truncate) numbers to their integer value.
 INT(x)
 PRINT INT(45.38)

LEFT$
 -- Return a partial copy of a string, starting at the leftmost character, and a specified number of characters in length.
 LEFT$(a$,x)
 C$=LEFT$("ABC",2)


LEN
 -- Return the number of characters in a string
 LEN(a$)
 PRINT LEN(C$)


LOG
 -- Return the natural logarithm of x.
 LOG(x)
 PRINT LOG(2.71828183)


LPOS
 -- Return the position of the printer's print head.
 LPOS(x)
 LPRINT "ABC";: PRINT LPOS(0)


MID$
 -- Return a partial copy of a string, starting at a specified character, and a specified number of characters in length.
 MID$(a$, s, l)
 A$=MID$("ABCDEFG", 3, 2)


PEEK
 -- Return the contents of a specified memory location.
 PEEK(x)
 N=PEEK(&HC000)


POKE
 -- To write data directly into a specified memory address.
 POKE memoryaddress, data
 POKE &HC200, &H41


POS
 -- Return the column of the current cursor position
 POS(0)
 PRINT "ABC"; : N=POS(0)


RIGHT$
 -- Return a partial copy of a string,  a specified number of characters in length, which is the rightmost part of the original string.
 RIGHT$(a$, x)
 C$=RIGHT$("ABCD",2)


RND
 -- Return a random number between 0 and 1.
 RND(x)
 N=RND(1)


SGN
 -- Return the sign of a number.  Returns -1 for negative numbers;  0 for 0;  and 1 for positive numbers.
 SGN(x)
 N=SGN(-2)


SIN
 -- Returns the sine of x radians.
 SIN(x)
 C=SIN(3.14159/2)


SPC
 -- To print a specified number of spaces on the screen or printer.
 SPC(x)
 PRINT SPC(5)


SQR
 -- Returns the square root of a number.
 SQR(x)
 N=SQR(64)


STICK
 -- Return the positional status of a specified joystick 0-2.
 STICK(x)
 N=STICK(1)


STRIG
 -- Return the status of the specified joystick 0-2 fire button.
 STRIG(x)
 N=STRIG(1)


STR$
 -- Returns a string which is a converted numeric value.
 STR$(x)
 A$=STR$(123.5)


TAB
 -- To move the cursor to a specified column position on the screen or printer.
 TAB(x)
 PRINT TAB(10);"abc"


TAN
 -- Returns the tangent of x radians.
 TAN(x)
 C=TAN(1.23)


VAL
 -- Return the numeric value of a string of numeric characters.
 VAL(a$)
 N=VAL("123")








