BASIC Command Reference

This information is largely copied from the Commodore 64 User's Guide, Appendix C, and the Commodore 64 Programmer's Reference Guide, Chapter 2, with a few additions and changes from yours truly.


ABS

TYPE: Function-Numeric
FORMAT: ABS(numeric)

Returns the absolute value of the number, which is its value without any signs. The absolute value of a negative number is that number multiplied by -1.

  10 X=ABS(Y)
  10 IF X=ABS(X) THEN PRINT "X IS POSITIVE"

AND

TYPE: Operator
FORMAT: expression AND expression

AND performs a Boolean bitwise AND operation with the two expressions, and can also be used to check the truth of two comparisons. Bitwise AND is performed on integers (fractions are truncated, if present) in the range from -32768 to +32767, which contain 16 bits. Numbers beyond that range will cause an ?ILLEGAL QUANTITY error message.

The Boolean use of AND is used to single out certain bits for comparison, or to clear bits from a value. The resulting number in an AND expression has its bits set only when the respective bits of both expressions are set. If a bit is clear in either of the expressions, the respective bit of the result will be clear as well. Example of Boolean usage:

  10 X=X AND MASK
  10 IF X AND 8 THEN PRINT "BIT THREE (2^3=8) IS SET"
  10 X=X AND (255-2^0-2^1-2^2):REM CLEAR LOWER 3 BITS
  10 X=X AND 248:REM SAME AS PREVIOUS LINE

If used in a true/false setting, AND will give the complete expression a true result only if both expressions are true. If any one is false, the entire expression is false. Example of truth usage:

  10 IF (X>0) AND (X<10) THEN PRINT "IN RANGE OF 0 TO 10"
  10 IF (A$<>"Y") AND (A$<>"N") THEN PRINT "TRY AGAIN"

Technically, any true result has a numeric value of -1 (a number with all bits set), and a false result returns a value of 0 (a number with all bits clear). In a true/false context, the AND operator still performs a boolean AND on all bits of the expressions. The only difference is that the expressions act as a single bit, with only 2 possible settings: -1 or 0.


ASC

TYPE: Function-Numeric
FORMAT: ASC(string)

This function will return the ASCII code (0-255) of the first character of a string. If the string is empty, a ILLEGAL QUANTITY ERROR will result. To prevent this, use

  N = ASC( A$ + CHR$( 0 ))

Note that in file I/O, when you read an ASCII character 0, the file routines will return an empty string, so the safeguard listed above is necessary in these cases. If a string is set to ASCII character 0 using the CHR$ function, it will have a length of 1 and ASC will work properly on it.


ATN (arctangent)

TYPE: Function-Numeric
FORMAT: ATN(numeric)

Returns the angle, measured in radians, whose tangent is X.

CHR$

TYPE: Function-String
FORMAT: CHR$(numeric)

This is the opposite of
ASC, and returns a single-character string character whose ASCII code is given. The code must be between 0 and 255, or an ILLEGAL QUANTITY ERROR will result.

CLOSE

TYPE: Statement-I/O
FORMAT: CLOSE filenumber

This command completes and closes any files used by
OPEN statements. The number following CLOSE is the file number to be closed, as specified in the corresponding OPEN statement. Any file that is opened in a program should be closed before the program ends. When writing to a file, not closing it properly could result in the file being lost.
  CLOSE 2           Only file #2 is closed

CLR

TYPE: Statement
FORMAT: CLR

This command will erase any variables in memory, but leaves the program itself intact. This command is automatically executed when a
RUN command is given. Use caution with this command, as any currently running FOR..NEXT loops and any GOSUB return addresses are forgotten, and OPENed files are not properly closed and are forgotten as well.

CMD

TYPE: Statement-I/O
FORMAT: CMD filenumber [,string]

CMD sends the output which normally would go to the screen (i.e.,
PRINT statements, LISTs, but not POKEs onto the screen) to another device instead. This could be a printer, a data file on tape or disk, or any other standard Commodore file. This device or file must be OPENed first. The CMD command must be followed by a number or numeric variable referring to the file. The string, if present, is sent before any other text, and is useful for prepending a title to the text.
  OPEN 1,4          OPENs device #4, which is the printer
  CMD 1             All normal output now goes to printer
  LIST              The program listing now goes to
                    the printer, not the screen
To send output back to the screen, issue a PRINT# command to send a blank line to finish off any unfinished lines, then CLOSE the file. Any error will revert output back to the screen. Devices are not CLOSEd; this must be done explicitly.

CONT

TYPE: Immediate Command
FORMAT: CONT

This command is used to continue the execution of a program which has been interrupted by either using the key, a
STOP statement, or an END statement within the program. The program will restart at the exact place from where it left off. This is useful for debugging or examining program states at certain locations in its execution.

CONT will not work if you have changed or added lines to the program, or if the program halted due to an error, or if you caused an error before trying to restart the program. In these cases you will get a CAN'T CONTINUE ERROR.


COS (cosine)

TYPE: Function-Numeric
FORMAT: COS(numeric)

Returns the value of the cosine of an angle measured in radians.

DATA

TYPE: Statement
FORMAT: DATA any [ ,any [,...]]

This statement stores information in a list of items which is to be used by
READ statements. Items may be numeric values or text strings, and items are separated by commas. String items need not be inside quote marks unless they contain space, colon, or comma. If two commas have nothing between them, the value will be READ as a zero for a number, or an empty string.
  DATA 12, 14.5, "HELLO, MOM", 3.14, PART1
The placement of DATA statements inside the program is not important, and these lines don't have to be RUN in order for the data to be available to READ statements. Thus, they are usually placed at the end of a program listing.

See the READ statement for a description of how the item list is handled.


DEF FN

TYPE: Statement
FORMAT: DEF FN variable(parameter) = formula

This command allows you to define a complex calculation as a function with a short name. In the case of a long formula that is used many times within the program, this can save time and space. One parameter variable is used in this definition, but the formula may use any variable to calculate its result, and does not have to use the parameter variable.

This function name will be FN and any legal variable name (1 or 2 characters long) and is followed by the parameter in parenthesis. This parameter will be substituted into the formula wherever the parameter variable is located.

  10 DEF FN A(X) = 2 * ( 6 - X / 3 )
  20 PRINT FN A(12)          ^
                ^            |
                |            | 12 is inserted where
                +------------+ X is in the formula

When RUN, this program displays "4" as the answer. The result of the formula is calculated every time the FN statement is used, using the value given in the parentheses.


DIM

TYPE: Statement
FORMAT: DIM variable ( size [ ,size [ ,... ]]) [ ,variable(size ...) ... ]

This statement defines an array, which is a group of variables of the same type, under the same variable name, each with an identifying number. The DIM statement is optional if you use small arrays of 11 or less elements. Keep in mind that the whole array takes up room in memory, so don't create an array much larger than you'll need. To figure the number of variables created with DIM, multiply the total number of elements (remember that element 0 is valid) in each dimension of the array.
  10 DIM A$(40), B7(15), CC%(4,4,4)
             ^       ^         ^
             |       |         |
   41 elements  16 elements  125 elements
You can dimension more than one array in a DIM statement. However, be careful not to dimension an array more than once.

END

TYPE: Statement
FORMAT: END

When a program encounters an END statement, the program halts without an error, behaving exactly as if it ran out of lines. You may use
CONT to continue the program from the command after the END statement. The only difference between this statement and the STOP statement is that STOP displays a BREAK IN LINE xxx, indicating where the STOP statement was encountered.

EXP

TYPE: Function-Numeric
FORMAT: EXP(numeric)

Returns the value of the mathematical constant e (2.71827183) raised to a power. The largest number than can be passed to this function is 88.0296919. Anything larger causes an OVERFLOW ERROR.

FN

TYPE: Function-Numeric
FORMAT: FN variable(numeric)

Returns the value of a user-defined function created in a
DEF FN statement.

FOR ... TO ... STEP

TYPE: Statement
FORMAT: FOR variable = numeric TO numeric [ STEP numeric ]

This statement works with the
NEXT statement to repeat a section of the program a set number of times. The FOR statement is the start point of this loop, and the variable is initialized to the numeric value before the TO keyword, and will be increased by the STEP number (1 if STEP is omitted) each time the loop is run, until the variable reaches the value after the TO keyword. The STEP value may be positive or negative, and may be integral or fractional. The entire loop is run at least once in all cases.

  10 FOR L = 1 to 10 STEP .1
  20 PRINT L
  30 NEXT L

The above program will print out 100 numbers from 1 to 10 in increments of .1.


FRE

TYPE: Function-Numeric
FORMAT: FRE(numeric)

This function returns the number of unused bytes available in memory, regardless of the value passed. Note that FRE(X) will read out n negative numbers if the number of unused bytes is over 32K, because the returned value is a signed 16-bit integer. To display the number of free bytes when the result is negative, add 65536 to the value returned.

This function also forces a "garbage collection" of BASIC variable and string space, which will compact memory usage, and also force the delay from this process to occur at a determined time.


GET

TYPE: Statement
FORMAT: GET variable [ ,variable [ ,...]]

The GET statement allows you to get data from the keyboard, one character at a time. When GET is executed, the character that is typed is assigned to the variable. If no character is typed, then a null (empty) character is assigned to a string variable, or a zero is assigned if the variable is numeric.

If a numeric variable was used and a nonnumeric key was pressed, the program would halt with a SYNTAX ERROR message. It is safer, when using this statement to get numeric values, to read keyboard entries as strings and to convert them to numeric values if they are actually numbers. The GET statement may be placed into a loop, checking for any result. The following line will loop until a key is hit:

  10 GET A$: IF  A$ = ""  THEN 10

GET#

TYPE: Statement
FORMAT: GET #filenumber, variable [ ,variable [ ,...]]

The GET# statement is used with a previously
OPENed device or file, to input one character at a time from that device or file. This would input one character from a data file:

  GET #1,A$
Note that this statement cannot be used in immediate mode.

GOSUB

TYPE: Statement
FORMAT: GOSUB linenumber

This statement is similar to
GOTO, except the computer remembers which program line it last executed before the GOSUB. When a line with a RETURN statement is encountered, the program jumps back to the statement immediately following the GOSUB. This is useful if there is a routine in your program that occurs in several parts of the program. Instead of typing the routine over and over, execute GOSUBs each time the routine is needed.

  20 GOSUB 800

GOTO or GO TO

TYPE: Statement
FORMAT: GOTO linenumber

When a statement with the GOTO command is reached, the program will continue on from the specified line number.

  20 GOTO 800

IF ... THEN

TYPE: Statement
FORMAT: IF expression THEN statement | linenumber

IF ... THEN lets the computer analyze a situation and take two possible courses of action, depending on the outcome. If the expression is true, the statement following THEN is executed. This may be any BASIC statement, or a line number to jump to. If the expression is false, the program goes directly to the next line.

The expression being evaluated may be a variable or formula, in which case it is considered true if nonzero, and false if zero. In most cases, there is an expression involving relational operators (=, <, >, <=, >=, <>, AND, OR, NOT).

  10 IF X > 10 THEN END
  20 IF X < 0 THEN 100

INPUT

TYPE: Statement
FORMAT: INPUT [ "prompt"; ] variable [ ,variable [ ,... ]]

The INPUT statement allows the program to get data from the user, assigning that data to a variable. The program will stop, print a question mark (?) on the screen, and wait for the user to type in the answer and hit RETURN.

INPUT is followed by a variable name, or a list of variable names, separated by commas. A message may be placed within quote marks, before the list of variable names to be INPUT. If more than one variable is to be INPUT, they must be separated by commas when typed.

  10 INPUT "PLEASE ENTER YOUR FIRST NAME";A$
  20 PRINT "ENTER YOUR CODE NUMBER";: INPUT B

INPUT#

TYPE: Statement
FORMAT: INPUT #filenumber, variable [ ,variable [ ,... ]]

INPUT# is similar to INPUT, but takes data from a previously
OPENed file or device.
  10 INPUT#1, A

INT

TYPE: Function-Numeric
FORMAT: INT(numeric)

Returns the integer value of a number, that is, with all the decimal places to the right of the decimal point removed. The result will always be less than, or equal to, the original number. Thus, any negative numbers with decimal places will become the integer less than their current value.

LEFT$

TYPE: Function-String
FORMAT: LEFT$(string,numeric)

Returns a string containing a number of the leftmost characters of the given string.

LEN

TYPE: Function-Numeric
FORMAT: LEN(string)

Returns the number of characters (including spaces and other symbols) in the string.

LET

TYPE: Command
FORMAT: LET variable = expression

This basically useless command is supported so that older BASIC programs can be run. The variable name which is to be assigned the result of a calculation is on the left side of the equal sign, and the formula in the right.
  10 LET A = 5
  20 LET D$ = "HELLO"
is the same as
  10 A = 5
  20 D$ = "HELLO"

LIST

TYPE: Immediate Command
FORMAT: LIST [ linenumber ] [-] [ linenumber ]

The LIST command displays a formatted, detokenized dump of what is currently residing in BASIC RAM, which is usually a BASIC program. You can ask for the entire listing to be displayed, or only certain line numbers.

Some program documentation, and the directory file of a disk are displayed with the LIST command, but are not BASIC programs themselves.

  LIST              Shows all lines
  LIST 10-          Shows only from line 10 until end
  LIST 10           Shows only line 10
  LIST -10          Shows lines from beginning until 10
  LIST 10-20        Shows line from 10 to 20, inclusive

LOAD

TYPE: Command
FORMAT: LOAD [ "filename" [ ,device [ ,flag ]]]

This command is used to transfer a program from tape or disk into memory so the program can be used. If no device number is given, 1 is assumed, which is the cassette unit. Devices 8-11 are the disk drives. If flag is non-zero, the file will be loaded to the address specified in the file. If the flag is zero or omitted, the file will load into the default BASIC RAM area. This is important for loading BASIC programs from other Commodore computers.

For tape operation, the filename can be omitted, and the first file encountered on the tape will be loaded. Disk operations require a filename to be specified. All standard filename wildcards and options are supported.

If the LOAD command is encountered inside a program, the BASIC interpreter will start executing the freshly loaded program from the first line. If flag is non-zero during a LOAD inside a program, the data will be loaded to the address specified in the file, and execution of the current program will restart. This is useful for loading data into memory without the use of DATA statements.

  LOAD              Reads in the next program on tape
  LOAD "HELLO"      Searches tape for program called HELLO,
                    and loads program, if found
  LOAD A$           Looks for program whose name is in the variable A$
  LOAD "HELLO",8    Looks for program called HELLO on the disk drive
  LOAD "*",8        Looks for first program on disk

LOG (logarithm)

TYPE: Function-Numeric
FORMAT: LOG(numeric)

Will return the natural log of a number. The natural log to the base e (see
EXP). To convert to log base 10, simply divide by LOG(10).

MID$

TYPE: Function-String
FORMAT: MID$(string,numeric1,numeric2)

This will return a string that contains numeric2 characters starting from the numeric1 character in the string.

NEW

TYPE: Command
FORMAT: NEW

This command sets the first program line to flag the end of the program, effectively erasing the entire program in memory. It also clears out any variables that may have been used. Unless the program was
SAVEd, it is lost. BE CAREFUL WHEN YOU USE THIS COMMAND.

The NEW command can also be used as a BASIC program statement. When the program reaches this line, the program is erased. This is useful if you want to leave everything neat when the program is done.


NEXT

TYPE: Statement
FORMAT: NEXT [ variable [ ,... ]]

NEXT is always used in conjunction with the
FOR statement. When the program reaches a NEXT statement, it checks the FOR statement to see if the limit of the loop has been reached. If the loop is not finished, the loop variable is increased by the specified STEP value. If the loop is finished, execution proceeds with the statement following NEXT.

NEXT may be followed by a variable name, or list of variable names, separated by commas. If there are no names listed, the last loop started is the one being completed. If variables are given, they are completed in order from left to right.

  10 FOR X = 1 TO 100: NEXT
  20 FOR X = 1 TO 5: FOR Y = 1 TO 5: PRINT X ; Y: NEXT Y,X

ON

TYPE: Statement
FORMAT: ON numeric GOTO|GOSUB linenumber [ ,linenumber [ ,... ]]

This command turns the
GOTO and GOSUB commands into special versions of the IF statement. ON is followed by a formula, which is evaluated. If the result of the calculation is one, the first line on the list is executed; if the result is 2, the second line is executed, and so on. If the result is 0, negative, or larger than the list of numbers, the next line executed will be the statement following the ON statement.

  10 INPUT X
  20 ON X GOTO 10,20,30,40,50

OPEN

TYPE: Statement
FORMAT: OPEN filenumber,device [ ,secondaryaddress [ ,"filename"|"command" ]]

Then OPEN statement allows the Commodore 64 to access devices such as the cassette recorder and disk for data, a printer, or even the screen. OPEN is followed by a number (0-255), to which all following statements will refer. There is usually a second number after the first, which is the device number.

The device numbers are:
0
1
4
8-11
Screen
Cassette
Printer
Disk
Following the device number may be a third number, separated again by a comma, which is the secondary address. In the case of the cassette, this is 0 for read, 1 for write, and 2 for write with end-of-tape marker. In the case of the disk drive, this is 0 for read, 1 for write, 2-14 for either read or write, and 15 for the command channel. When 2-14 are used on the disk, the
filename options ",W", ",R", and ",A" specify write, read, or append, respectively.

In the printer, the secondary address controls features like expanded printing. See your printer's manual for details.

  10 OPEN 1,0           OPENs the SCREEN as a device
  20 OPEN 2,1,0,"D"     OPENs the cassette for reading,
                        file to be searched for is D
  30 OPEN 3,4           OPENs the printer
  40 OPEN 4,8,15        OPENs the data channel on the disk
Once a file has been opened, the CLOSE, CMD, GET#, INPUT#, PRINT# statements can be used with the filenumber specified, and the system variable ST is activated.

PEEK

TYPE: Function-Numeric
FORMAT: PEEK(address)

Used to find out contents of a memory location, in the range 0-65535, giving a result from 0-255. PEEK is often used in conjunction with the
POKE statement.

POKE

TYPE: Statement
FORMAT: POKE address, numeric

POKE stores a numeric value (integer from 0 to 255) into a memory location (integer from 0 to 65535). Fractional numbers will be rounded, and any value outside of the limits will cause an error. Any previous value in the memory address is overwritten.
  10 POKE 53281,0
  20 S = 4096 * 13
  30 POKE S + 29, 8

POS

TYPE: Function-Numeric
FORMAT: POS(numeric)

This function returns the number of the column (0-39) at which the next
PRINT statement will begin on the screen. The numeric value passed is not used.

PRINT

TYPE: Statement
FORMAT: PRINT [expression] [ ; | , ] [expression] ...

The PRINT statement is the first one most people learn to use, but there are a number of variations to be aware of. PRINT can be followed by:

Text String with quotes
Variable names
Functions
Punctuation marks

Punctuation marks are used to help format the data on the screen. The comma divides the screen into four columns, while the semicolon suppresses all spacing. Either mark can be last symbol on a line. This results in the next thing PRINTed acting as if it were a continuation of the same PRINT statement. To save space in the program the punctuation can be omitted, which will behave the same way as a semicolon, but it must be obvious to the interpreter that two expressions are distinct (ie. PRINT AB will print the variable AB, not variable A followed by B).

  10 PRINT "HELLO"
  20 PRINT "HELLO", A$
  30 PRINT "HELLO"A$
  40 PRINT A + B
  50 PRINT J;
  60 PRINT A, B, C, D
See also
POS, SPC and TAB functions.

PRINT#

TYPE: Statement
FORMAT: PRINT #filenumber [ ,expression [ ; | , ] expression ... ]

There are a few differences between this statement and
PRINT. PRINT# is followed by a number, which refers to the device or data file previously OPENed. This number is followed by a comma and a list to be printed. The comma and semicolon have the same effect as they do in PRINT. Please note that some devices may not work with TAB and SPC.
  100 PRINT#1, "DATA VALUES"; A%, B1, C$

READ

TYPE: Statement
FORMAT: READ variable [ ,variable ...]

READ is used to assign information from
DATA statements to variables, so the information may be put to use. Care must be taken to avoid READing strings to numeric variables, which will give a TYPE MISMATCH ERROR. When reading strings, all leading and trailing spaces are truncated, unless the spaces reside in quotation marks.

  10 READ NM$, PH, A$
  20 DATA "JOHN DOE", 5551212, SOME GUY

REM (Remark)

TYPE: Statement
FORMAT: REM [anything...]

REMark is a note to whomever is reading a
LIST of the program. It may explain a section of the program, or give additional instructions. REM statements in no way affect the operation of the program, except to add to its length. REM may be followed by any text.

RESTORE

TYPE: Statement
FORMAT: RESTORE

When executed in a program, the pointer to which the next
DATA statement will be READ next is reset to the first existing DATA statement in the program. This gives you ability to re-READ the information. RESTORE stands by itself on a line.

RETURN

TYPE: Statement
FORMAT: RETURN

This statement is always used in conjunction with
GOSUB. When the program encounters a RETURN, it will go to the statement immediately following the most recent GOSUB command. If no GOSUB was previously issued, a RETURN WITHOUT GOSUB ERROR will occur. GOSUBs and RETURNs may be nested, so that one routine may GOSUB another, and the first routine's RETURN will return properly to the program.

RIGHT$

TYPE: Function-String
FORMAT: RIGHT$(string,numeric)

Returns a string containing a number of the rightmost characters in the string.

RND (random number)

TYPE: Function-Numeric
FORMAT: RND(numeric)

RND returns a random number in the range 0-1. The numeric parameter can have three functions. If a negative value is used, it will reseed the generator. The use of the same negative number will result in the same sequence of "random" numbers. If zero is used, the result will be the same random number as the last one. Any positive number will generate the next "random" number. To generate different random numbers every time, seed the random number generator with RND(-TI) first.

The formula for generating a number between 0 and X is:

  N = RND(1) * X
To generate a number between X and Y, use

  N = RND(1) * (Y - X) + X

RUN

TYPE: Command
FORMAT: RUN [linenumber]

This command causes execution of a program, once the program is loaded into memory. If there is no line number following RUN, the computer will start with the first line of the program. If a line number is designated, the program will start executing from the specified line.
  RUN               Starts program at the first line
  RUN 100           Starts execution at line 100
  RUN X             UNDEFINED STATEMENT ERROR. You must always specify an
                    actual line number, not a variable representation

SAVE

TYPE: Command
FORMAT: SAVE [ "filename" [ ,device [ ,flag ]]]

This command will store the program currently in memory on cassette or disk. If no device number is given, 1 is assumed, which is the cassette unit. Devices 8-11 are the disk drives.

For tape operation, the filename can be omitted, and the file will be saved as an unnamed file. The flag only has meaning to tape files, and signals that the saved file is the last file on the tape. Be careful with where the tape is queued up to, as saving to tape will record over any residing data just as recording to audio tapes will record over audio. Disk operations require a filename to be specified. Standard filename options are permitted, but wildcards are not.

  SAVE              Stores program to tape without name
  SAVE "HELLO"      Stores on tape with name HELLO
  SAVE A$           Stores on tape with name A$
  SAVE "HELLO",8    Stores on disk with name HELLO
  SAVE "HELLO",1,1  Stores on tape with name HELLO and follows
                    program with END-OF-TAPE marker

SGN (sign)

TYPE: Function-Numeric
FORMAT: SGN(numeric)

This function returns the sign (positive, negative, or zero) of the numeric value. The result will be +1 if positive, 0 if zero, and -1 if negative.

SIN (sine)

TYPE: Function-Numeric
FORMAT: SIN(numeric)

Returns the value of the trigonometric sine of an angle measured in radians.

SPC

TYPE: Keyword
FORMAT: PRINT [...] SPC(numeric) [...]

This is used in a
PRINT statement to skip a number of spaces forward. The spaces skipped are not overwritten with space characters.

SQR (square root)

TYPE: Function-Numeric
FORMAT: SQR(numeric)

This function will return the square root of a positive number or zero. If a negative number is given, an ILLEGAL QUANTITY ERROR results.

STEP

TYPE: Keyword
FORMAT: FOR variable = numeric TO numeric STEP numeric

See
FOR...TO...STEP.

STR$

TYPE: Function-String
FORMAT: STR$(numeric)

This will return a string which is identical to the
PRINTed version of the number.

STOP

TYPE: Statement
FORMAT: STOP

This statement will halt program execution. The message, BREAK IN xxx will be displayed, where xxx is the line number containing STOP. The program may be restarted by using the
CONT command. STOP is normally used in debugging a program.

SYS

TYPE: Statement
FORMAT: SYS address

SYS is followed by a decimal number or numeric value in the range 0-65535. The program will then begin executing the machine language program starting at that memory location. This is similar to the
USR function, but does not incorporate BASIC parameter passing. To interface with the machine language routine, you can store .A, .X, .Y, and .P into locations 780, 781, 782, and 783, respectively. The routine can exit with a standard RTS instruction, and locations 780-783 will be updated with the new values of the processor registers.

TAB

TYPE: Keyword
FORMAT: PRINT [...] TAB(numeric) [...]

TAB is also used in a PRINT statement; the next item to be PRINTed will be in column X.

TAN (tangent)

TYPE: Function-Numeric
FORMAT: TAN(numeric)

Returns the value of the tangent of an angle measured in radians.

THEN

TYPE: Keyword
FORMAT: IF expression THEN statement | linenumber

See
IF...THEN.

TO

TYPE: Keyword
FORMAT: FOR variable = numeric TO numeric [ STEP numeric ]
FORMAT: GO TO linenumber

See
FOR...TO...STEP or GOTO.

USR

TYPE: Function-Numeric
FORMAT: USR(numeric)

When this function is used, the program jumps to a machine language program whose starting point is contained in memory locations 785-786. The parameter is copied into Floating Point Accumulator #1, and the value in this location after the machine language routine ends (with a standard
RTS instruction) will be returned back to the BASIC program. Refer to the Commodore 64 Programmer's Reference Manual for more details on this function and machine language programming.

VAL

TYPE: Function-Numeric
FORMAT: VAL(string)

This function converts a string into a number, and is essentially the inverse operation from
STR$. The string is examined from the leftmost character to the right, for as many characters as are in recognizable number format.

  10 X = VAL("123.456")             X = 123.456
  10 X = VAL("12A13B")              X = 12
  10 X = VAL("RIU017")              X = 0
  10 X = VAL("1.56E3")              X = 1560
  10 X = VAL("-1.23.45.67")         X = -1.23

VERIFY

TYPE: Command
FORMAT: VERIFY [ "filename" [ ,device ]]

This command essentially performs a
LOAD, but only checks the data in the file against the current BASIC program instead of storing it in memory. This command is used to check that a file has been saved correctly, and that the tape or disk is retaining the information properly. The filename and device options are the same as the LOAD command.

  VERIFY            Checks the next program on tape
  VERIFY "HELLO"    Searches for HELLO, checks against memory
  VERIFY "HELLO",8  Searches for HELLO on disk, then checks
                    against memory

WAIT

TYPE: Statement
FORMAT: WAIT address, mask [ ,xormask]

WAIT is used to halt the program until the contents of a memory location changes in a specific way. WAIT is followed by a memory location and up to two variables.

The contents of the memory location are first exclusive-ORed with the third number, if present, and then logically ANDed with the second number. If the result is zero, the program goes back to that memory location and checks again. When the result is nonzero, the program continues with the next statement.

To WAIT for a certain bit to be set, simply set the bit in the mask variable (leave the bit clear in xormask, if it's used). To WAIT for a certain bit to be cleared, set the bit in both the mask and xormask variables.


All pages were generated with a text editor.
All images (except counter art and host ads) are generated, owned and (c) by
me.

Home - Files - Super Reference 1