Assign a value to a variable. Variable names can be up to 31 significant characters, consisting of letters, digits, underscores, and an ending dollar sign. Variable names are case insensitive. Variables can hold real numbers (IEEE double) or strings of up to 254 characters. If the variable name ends with a "$
" it holds strings, otherwise it holds numbers. If a statement starts with a variable name then an implied LET
is assumed.
This command will print its parameters tab delimited. If a semi-colon is used between parameters then no tab is inserted between the parameters. The print output is terminated with a carriage return unless the parameter list ends with a semi-colon. If a file descriptor is given then output is redirected to the given file. If a tab(VAL);
is found in a print statement, then print output will skip to the horizontal position specified by VAL
.
Prints formatted numbers. Legal characters for the format string STRINGVAL
are: + * $ # . E+
and trailing spaces.
print using "**$###.##"; 1.23 :' ****$1.23
print using "###.##"; 2.12345 :' 2.12
print using "#.##E+##"; 2345.6 :' 2.35E+03
Input from the console or from the file specified by FNUM
. If the input is from the console then a prompt string can optionally be printed.
All input to string variables is "line input"; a whole input line will be read into one string variable. The number of comma seperated numeric values in the input data must be less than or equal to the number of numeric variables in the INPUT
statement. This INPUT
usage is different from other versions Basic.
Gets one character from the console keyboard. Blocking.
Writes one byte to the file specified by FNUM
.
Reads one record from a random access file into VAR
.
Write one record to a random access file from VAR
.
Clear the terminals screen. Leaves the cursor in the upper left corner. For Applesoft BASIC fans, the "home
" command will also do this.
Terminates program execution and returns to the command prompt. Not required.
Stops the execution of the program and returns to the command prompt. Prints a "Break...
" message.
The IF
statement. If the condition is true then the STATEMENTS
after the THEN
are executed and the statements after the ELSE
are skipped. If the condition is false then the statements after the "else" are executed instead. If the item after "then
" is a line number then a goto is executed.
If there is no THEN
keyword on the same line and the condition is true, then statements are executed until a line starting with an ENDIF
is found. It false, then statements are skipped until a line starting with an ENDIF
keyword is found (block IF() ... ENDIF
statements). ELSE
and ELSEIF ()
keywords may be used on lines in between the IF
and the ENDIF
statements.
Beginning of a FOR-NEXT
loop. It takes a starting value, a limit and an optional step argument. If the step value is negative, the variable counts down. The body of the loop is not executed if the end condition is true initially.
for i=1 to 10 : print i, : next i
rem prints the numbers from 1 through 10
End of a FOR-NEXT
loop. If the termination condi- tions are met then execution falls through to the following statement, otherwise execution returns to the statement following the FOR
statement with the corresponding index variable. If there no index variable parameter, the innermost FOR
loop is used.
Exits the current FOR-NEXT
loop.
Start of a WHILE
loop. The loop is repeated until EXPR
is false. If EXPR
is false at loop entry, then the loop is not executed . A WHILE
loop must be terminated by a balancing WEND
statement.
Terminating statement of a WHILE
loop. If EXPR
is true then exit the loop. Only one WEND
is allowed for each WHILE
. A WHILE-WEND
loop without a condition will loop forever.
Exits the current WHILE-WEND
loop.
Transfer command to a line number. Save return address so that the program can resume execution at the statement after the "gosub
" command. The recursion depth is limited only by available memory.
Returns from the most recently activated subroutine call (which must have been called by GOSUB
).
This statement will transfer control to the line number specified. If the program is not running, then this command will begin execution at the spec- ified line without clearing the variables. An "Undefined line
" error will occur if LINENUM
doesn't exist in the program.
This command will execute either a goto or a gosub to the specified line number indexed by the value of EXPR
. If EXPR
is larger than the number of LINENUM
s, then control passes to the next statement.
If the error form is used, only one linenumber is allowed. LINENUM
is the line to which control is transferred if an error occurs. A GOTO
or CONT
statement can be used to resume execution. An error inside a named SUB
subroutine cannot be resumed from or CONT
inued.
Subroutine entry. May be called by a CALL
statement or by NAME
. A SUB
subroutine must be exited by a RETURN
or END SUB
statement. There should be only one RETURN
or END SUB
statement per SUB
definition. The variables in the VAR
list become local variables. String and numeric arguments are passed by value; array arguments must be pre-dimensioned and are passed by reference.
110 x = foo (7, j) : rem Pass 7 and j by value.
...
2000 sub foo (x,y,z) : rem z is a local variable
2010 print x : rem prints 7
...
2080 foo = y+1 : rem return value
2090 end sub
Subroutine definitions may not be nested.
To return a value from a named subroutine terminated with end sub
, set the name of the subroutine equal to the desired return value. Also, if the value to be returned is a string value, the subroutine name must end with a '$
' character, as with all string variables.
Multi-way branch. Executes the statements after the CASE
statement which matches the SELECT CASE
expression, then skips to the END SELECT
statement. If there is no match, and a CASE ELSE
statement is present, then execution defaults to the statements following the CASE ELSE
.
200 select case x
210 case 2
...
230 case 3, 4
...
270 case else
...
290 end select
Dimension an array or list of arrays (string or numeric). A maximum of 4 dimensions can be used. The maximum dimension size is limited by available memory. Legal array subscripts are from 0 up and including the dimension specified; d+1
elements are allocated. All arrays must be dimensioned before use.
10 dim a(10)
20 for i=0 to 10
30 a(i) = i^2
40 next i
50 print a(5)
60 rem should print 25
DATA
statements contain the data used in the READ
statements. Items must be separated by commas. The items may be either numeric or string expressions, corresponding to the type of variable being read. Reading the wrong kind of object produces a "Type mismatch
" error. Strings must be encapsulated with quote marks.
Read data from the DATA
statements contained in the program. List items can be either string or numeric variables. Reading past the end the last DATA
statement generates an error.
The RESTORE
statement causes the next READ
to use the first DATA
statement in the program. If a LINENUM
is given then the DATA
statement on or after that particular line is used next.
A remark or comment statement. Ignored by the program during execution, however a REM
statement can be the target of a GOTO
or GOSUB
.
Open a file. The { input|output|append }
parameter specifies whether the file is to be read, written or appended. If STRINGEXPR
is "stdin
" for input or "stdout
" for output then the console will be used instead of a file. A "file not found
" error will occur if a non-existant file is specified in an OPEN
for input statement. FNUM
must be an integer value between 0 and 8.
Opens a random access file. Only GET
and PUT
statements are allowed to read and write random access files.
See OPEN
command. LINENUM
is the line to which control is transferred if an error in opening a file occurs. The variable ERL
is set to the line number on which the file open error occured.
Close a file. Releases the file descriptor and flushes out all stored data.
Define a user definable function. Obsolete.
10 def fnplus(x,y) = x+y
20 print fnplus(3,5)
30 rem - should print 8
Fills a 1 or 2 dimensional array with a constant value given by EXPR
.
Copys a 2 dimensional array. The dimensions must match.
Inverts a 2 dimensional square array. LINENUM
is the line to which control is transferred if the matrix is singular.
Transposes a 2 dimensional array. The dimensions of the first array must correspond to the transpose of the dimensions of the second array.
Adds or multiplies a 2 dimensional array by either an expression or another array. The dimensions must be appropriate for matrix addition or matrix multiplication.
Sets the matrix index origin to either 0 or 1 for all MAT
statements, including fill. Defaults to 0.
Creates a structure definition type. Each field requires a separate line. Legal types are string, integer, longint and double. The definition must conclude with an END TYPE
statement. Use the DIM AS NEW
statement to create records containing the structure specified by a TYPE
statement.
300 type person
310 name as string * 32
311 rem 31 chars in length
320 age as integer
312 rem 2 byte integers
330 weight as double
331 rem 8 byte doubles
340 end type
400 dim friend1 as new person
410 friend1.name = "Mark"
420 friend1.age = 13
430 print friend1.name, friend1.age
Creates a class definition. Class definitions can then be used to create objects with member functions (also called methods). Classes inherit members from superclasses (single inheritance).
CLASS bar
y AS integer
z AS PRIVATE double ' private data
s AS PUBLIC string ' public keyword optional
SUB blah(v) ' public member function
this.y = v + 7
END SUB
END CLASS
DIM b AS NEW bar ' create object b
CALL b.blah(1) ' send message "blah(1)" to b
CLASS
and TYPE
definitions are global, and cannot be nested inside other class definitions or subroutines.
Create a record (TYPED-VAR
) or object using a previously defined structure definition type created by TYPE...END TYPE
or CLASS...END CLASS
. Optionally creates an array of records or objects.
Un-dimensions a dimensioned array. Frees memory.
Changes the trigonometric functions to take parameters and return results in degrees instead of radians.
Replace the sub-string in STRINGVAR
, starting at character position EXPR1
, with character length EXPR2
, with the (EXPR2
in length) string STRINGEXPR
. See MID$
.
Replace the N-th field of STRINGVAR
with STRINGEXPR
. See FIELD$
.
Poke a byte into a memory location. Unreasonable addresses can cause bus or segmentation errors.
Pushes one or more expressions or variables onto an internal stack. Expressions can be returned using the POP
function; variables can be returned by using the POP
statement.
POP
statement (see also POP
function). Pops VAL
variables off the internal stack, restoring the value of those variables to their pushed values.
Executes STRINGEXPR
as a statement or command. E.g., exec("print " + "x")
will print the value of x
.