BASIC09 (quick Reference

This chapter contains a quick reference of all BASIC09 commands, statements, and functions. It includes commands for pro-

gramming, editing, and debugging, as well as the Commands
mode commands.

The following chart lists all BASIC09 keywords that you can use in a procedure.


Statements and Functions

Command Description
ABS Returns the absolute value of a number.
ACS Calculates the arccosine of a number.
ADDR Returns an integer value which is the abso
lute memory address of a variable, array, or
structure in a process's address space.
AND Generates the logical AND of two Boolean
values.
ASC Returns the ASCII code of the first charac
ter in a string.
ASN Calculates the arcsine of a number.
ATN Calculates the arctangent of a number.
BASE Sets the lowest array or data structure sub
script in a procedure to either 0 or 1.
BYE Ends execution of a procedure and termi
nates BASIC09.
CHAIN Executes a module, passing arguments if
appropriate.
CHD Changes the current data directory. -
CHR$ Returns the ASCII character represented by
a specified integer.
CHX Changes the current execution directory.
CLOSE Deallocates the specified path to a file or
device.
COs Calculates the cosine of a number.


BASIC09 Reference

Command Description
CREATE Opens a path and establishes a new file on
disk. ''
DATE$ Returns the computer's current date and
time.
DEG Causes BASIC09 to calculate angles in
degrees.
DATA Stores data in a procedure to be accessed
by the READ statement.
DELETE Deletes a file from disk.
DIM Declares simple variables, arrays or complex
data structure for size and type.
DO See WHILE/DO/ENDWHILE.
ELSE See IF/THEN/ELSE/ENDIF.
END Terminates execution of a procedure.
Returns to the calling procedure or to
BASIC09's command mode. Displays the

specified text.
ENDEXIT See EXITIF/ENDEXIT.
ENDIF See IF/THEN/ELSE/ENDIF.
ENDLOOP See LOOP/ENDLOOP.
ENDWHILE See WHILE/DO/ENDWHILE.
EOF Tests for the end of a disk file.
ERR Returns the error code of the most recent
error.
ERROR Generates the specified error.
EXITIF/ Tests conditions in a loop. The procedure
ENDEXIT exits the loop if the condition is true.
EXP Calculates a (2.71828183) raised to the
specified value. _
FALSE A Boolean function that always returns

FALSE.
FIX Rounds a real number and converts it to an
integer.
FLOAT Converts a byte or integer value to a real
number.
10-2
BASIC09 Quick Reference l 10

Command
FOR/NEXT

Description

Creates a program loop of a specified number of repetitions.


Reads an element or a data structure from a binary file or a device.


Transfers program control to a specified subroutine. RETURN sends execution back to the calling routine.


Evaluates an expression and performs an operation if the conditions are met. Including ELSE causes an alternate operation if the conditions are false.


Stores the character of a keypress in a string variable.


Causes a procedure to accept input from the keyboard or other specified device.


Returns the largest whole number less than or equal to the specified value.


Unlinks a procedure. (Removes it from BASIC09's directory.)


Performs a bit-by-bit logical AND on two-byte, or integer, values.


Returns the specified number of characters, from the leftmost portion of a string.


Returns the length of the specified string.

Assigns a value to a variable.

Performs a bit-by-bit logical NOT function on two-byte, or integer, values.


Calculates the natural logarithm.

Calculates a base 10 logarithm.

Establishes a loop. Use EXITIF and ENDEXIT to test the loop and exit when a specified condition is true.


Performs a bit-by-bit logical OR on twobyte, or integer, values.


GET

GOSUB/
RETURN

IF/THEN/ELSE/
ENDIF

INKEY

INPUT

INT

KILL

LAND

LEFT$

LEN
LET
LNOT

LOG
LOG10
LOOP/
ENDLOOP

LOR

10-3
BASIC09 Reference

Command Description
LXOR Performs a bit-by-bit logical EXCLUSIVE


MID$ Returns the specified number of characters,
beginning at the specified position in a
string.
MOD Returns the modulus (remainder) of a divi
sion operation.
NEXT See FOR/NEXT.
NOT Returns the logical complement of a Boolean
value.
ON ERROR/ Traps errors and transfers control to the
GOTO specified line number.
ON/GOSUB Evaluates an expression. Then, selects from
a list the line number that is in the posi
tion indicated by the result of the expres
sion. Procedure execution transfers to the
selected line.
ON/GOTO Evaluates an expression. Then, selects from
a list the line number that is in the posi
tion indicated by the result of the expres
sion. Procedure execute jumps to the
selected line.
OPEN Opens an I/O path to an existing file or
device.
OR Performs a logical OR on two Boolean
values.
PARAM Describes the parameters a called proce-


PAUSE Suspends execution of a procedure, and
enters the Debug mode.
PEEK Returns the byte value of a memory
address.
PI Represents the constant 3.14159265.
POKE Stores a byte value at a specified memory
address.
POS Returns the current character position of
the print buffer.

10-4


Command Description
PRINT Sends the specified characters or values to
the display.
PRINT USING Sends characters or values to the display,
using the specified format.
PRINT# Sends the specified characters or values to
the specified path.
PRINT# USING Sends characters or values to the specified
path using the specified format.
PUT Writes data to a random access file.
RAD Causes BASIC09 to calculate angles in
radians.
READ Accesses data from procedure DATA lines or
from files or devices.
REM Indicates that the following characters in a
procedure line are comments and are not to
be executed. Also use (* *), or (*.
REPEAT/UNTIL Establishes a loop that executes until the
specified condition is met.
RESTORE Restores the DATA pointer to the first data
item or to a specified line.
RETURN See GOSUB/RETURN.
RIGHT$ Returns the number of characters specified,
from the rightmost portion of a string.
RND Returns a random number from a specified
range.
RUN Calls another procedure for execution.
SEEK Changes the file pointer address.
SGN Determines the sign of a number.
SHELL Calls an OS-9 command or program for
execution.
SIN Calculates the sine of a specified value.
SIZE Returns the number of bytes assigned to a
variable, array, or complex data structure.
SQ Calculates a value raised to the power of
two.
10-5
BASIC09 Reference

Command Description
SQR/SORT Calculates the square root of a positive
number. ~"1
STEP Sets the size of increment in a FOR/NEXT
loop.
STOP Terminates the execution of all procedures
and returns to the BASIC09 Command
mode.
STR.$ Converts numeric data to string data.
SUBSTRING Returns the starting position of a sequence
of characters in a string.
SYSCALL Executes an OS-9 System Call.
TAB Begins a print operation at the specified
column.
TAN Calculates the tangent of a value.
TRIM$ Strips trailing spaces from the specified
string.

TRON/TROFF Turn the trace mode on and off.

TRUE Returns the Boolean value of TRUE.
TYPE Defines a new data type.
UNTIL See REPEAT/UNTIL.
USING See PRINT USING.
VAL Converts a string to an integer.
WHILE/DO/ Executes a loop as long as a specified condi
ENDWHILE tion is true.
WRITE Writes data in ASCII format to a file or
device.
XOR Performs a logical EXCLUSIVE OR on two
Boolean values.

10-6
                  BASIC09 Quick Reference l 10


Commands by Type

Statements

BASE 0 DIM GOSUB OPEN RETURN
BASE 1 ELSE GOTO PARAM RUN
BYE END IF/THEN PAUSE SEEK
CHAIN ENDEXIT INPUT POKE SHELL
CHD ENDIF KILL PRINT STOP
CHX ENDLOOP LET PUT TROFF
CLOSE ENDWHILE LOOP RAD TRON
CREATE ERROR NEXT READ TYPE
DATA EXITIF/THEN ON ER.RORJGOTO REM UNTIL
DEG FOR/TO/STEP ON/GOSUB REPEAT WHILE/DO
DELETE GET ON/GOTO RESTORE WRITE

Transcendental Functions
ACS Cos LOG10 SIN
ASN EXP PI TAN
ATN LOG
Numeric Functions

    ABS LAND MOD SQ

    FIX LNOT RND SQR

    FLOAT LOR SGN SQRT

    INT LXOB


String Functions

    ASC LEFT$ RIGHT$ TRIM$

    CHR$ LEN STR$ VAL

    DATE$ MID$ SUB STR

    INKEY


Miscellaneous Functions

    ADDR FALSE SIZE SYSCALL

    EOF PEEK TAB

    ERR POS TRUE


r

                                    10-?

BASIC09 Reference

Data Types

The following list shows the BASIC09 data type you can specify when defining a variable.


Type Function
BOOLEAN Returns TRUE or FALSE
BYTE Specifies that a numeric variable is to store
single-byte values.
INTEGER Specifies that a numeric variable is to store
integer (two-byte) values.
REAL Specifies that a numeric variable is to store
real (five-byte) values.
STRING Specifies that a variable is to store ASCII
characters.

Types of Access for Files

You can use the following parameters with the CREATE and OPEN commands. Check the individual commands for information on which parameter to use with which command.


Parameter Function
DIR Lets BASIC09 access a directory-type file
for reading. Do not use with UPDATE or
WRITE.
EXEC Lets BASIC09 access the current execution
directory rather than the current data
directory.
READ Sets the file access mode for reading.
WRITE Sets the file access mode for writing.
UPDATE Sets the file access mode for both reading
and writing.

10-8
                  BASIC09 Quick Reference l 10


Command Mode

The following chart lists the commands available from the
BASIC09 Commands mode:

Command Function
$ Calls the shell command interpreter to exe-
            cute an OS-9 command.

BYE or Returns you to the OS-9 system or to the
CTRL BREAK program that called BASIC09.
CHD Changes the current data directory.
CHX Changes the current execution directory.
DIR Displays the name, size, and variable stor
age requirement of each procedure in the
workspace.
EDIT or E Enters the procedure editor/compiler mode
KILL Removes one or more procedures from the
workspace.
LIST Displays a formatted listing of one or more
procedures.
LOAD Loads all procedures from a file into the
workspace.
MEM Displays current workspace size or reserves
a specified amount of memory for the
workspace.
PACK Performs a second compilation and stores
the resulting file in the execution directory.
RENAME Changes a procedure's name.
RUN Causes a procedure to execute.
SAVE Writes one or more procedures to disk.

10-9
BASIC09 Reference

Edit Commands

The following chart lists the commands available from the Edit mode:

Command Function
ENTER Moves the edit pointer to the next line.
+ num Moves the edit pointer forward a specified
number of lines.
+ * Moves the edit pointer past the last line.
- num Moves the edit pointer back a specified
number of lines.
- * Moves the edit pointer to the first line.
text A space followed by text inserts an unnum
bered line before the current line.
line Typing a line number with or without text
following it inserts the line into the
procedure.
line ENTER Moves the edit pointer to the line line.
cl strllstr2l Changes the text strl to the text str2.
c*l strllstr2 Changes all occurrences of strl to str2.
d Deletes the current line.
d* Deletes all the lines in the procedure.
1 Lists the current line.
1* Lists all the lines in the current procedure.
q Terminates the edit session.
r Renumbers lines from the first line number,
in increments of 10.
r* Renumbers all numbered lines in incre
ments of 10. The first line number is 100.
r line Renumbers lines from line in increments- of
10.
r line n um Renumbers lines from line, in increments of
num.
sl str Searches for the first occurrences of str.
s*l str Searches for all occurrences of str.

10-10
                  BASIC09 Quick Reference l 10


Debug Commands

The following table lists all the Debug commands and what they accomplish:


Command Function
$command Tells BASIC09 to execute the specified OS-9
command or program.
BREAK Sets a breakpoint at the specified
procedure.
CONT Causes procedure execution to continue.
DEG/R,AD Selects either degrees or radians as the unit
of angle measurement for trigonometric
functions.
DIR Displays the procedures in the workspace.
Q Leaves the Debug mode for the System
mode.
LET Assigns a new value to a variable.
LIST Displays a source listing of the suspended
procedure.
PRINTvar Displays the value of the specified variable.
STATE Lists the nesting order of all active
procedures.
STEPnum Causes execution of the suspended proce
dure in specified increments.
TRON/TROFF Turns the trace function on and off.

10-11