.pa 1
.he 'BAS (I)'1/15/73'BAS (I)'
.ti 0
NAME		bas -- basic
.sp
.ti 0
SYNOPSIS	bas___ [ file ]
.sp
.ti 0
DESCRIPTION	bas___
is a dialect of basic [1].
If a file argument is provided,
the file is used for input before the console
is read.
.sp
bas___ accepts lines of the form:
.sp
   statement
   integer statement
.sp
Integer numbered statements
(known as internal statements)
are stored for later execution.
They are stored in sorted ascending order.
Non-numbered statements are immediately executed.
The result of an immediate expression statement
(that does not have '=' as its highest operator) is printed.
.sp
Statements have the following syntax:
.sp
.in +6
.ti -3
expression
.br
The expression is executed for its side
effects (assignment or function call)
or for printing as described above.
.sp
.ti -3
done____
.br
Return to system level.
.sp
.ti -3
draw____ expression expression expression
.br
A line is drawn on the Tektronix 611 display (/dev/vt0) from
the current display position
to the XY co-ordinates specified by the
first two expressions.
(The scale is zero to one in both X and Y directions)
If the third expression
is zero, the line is invisible.
The current display position is set to the end point.
.sp
.ti -3
display_______ list
.br
The list of expressions and strings is
concatenated and displayed (i.e. printed) on the 611 starting
at the current display position.
The current display position is not changed.
.sp
.ti -3
erase_____
.br
The 611 screen is erased.
.sp
.ti -3
for___ name =_= expression expression statement
.ti -3
for___ name =_ expression expression
.br
.li
...
.ti -3
next____
.br
The for___ statement
repetitively executes a
statement (first form)
or a group of statements (second form)
under control of a named variable.
The variable takes on the value of
the first expression,
then is incremented by one on each loop,
not to exceed the value of
the second expression.
.sp
.ti -3
goto____ expression
.br
The expression is evaluated, truncated to an integer
and execution goes to the corresponding integer numbered statment.
If executed from immediate mode,
the internal statements are compiled first.
.sp
.ti -3
if__ expression statement
.br
The statement is executed if the expression evaluates
to non-zero.
.sp
.ti -3
list____ [expression [expression]]
.br
list____ is used to print out the stored internal statements.
If no arguments are given, all internal statements are printed.
If one argument is given, only that
internal statement is listed.
If two arguments are given, all internal statements
inclusively between the arguments are printed.
.sp
.ti -3
print_____ list
.br
The list of expressions and strings are concatenated and
printed.
(A string is delimited by " characters.)
.sp
.ti -3
return______ [expression]
.br
The expression is evaluated and the result is passed
back as the value of a function call.
If no expression is given, zero is returned.
.sp
.ti -3
run___
.br
The internal statements are compiled.
The symbol table is re-initialized.
The random number generator is re-set.
Control is passed to the lowest numbered internal
statement.
.sp
.ti -6
Expressions have the following syntax:
.sp
.ti -3
name
.br
A name is used to specify a variable.
Names are composed of a letter ('a' - 'z')
followed by letters and digits.
The first four characters of a name are significant.
.sp
.ti -3
number
.br
A number is used to represent a constant value.
A number is composed of digits, at most one decimal point ('.')
and possibly a scale factor of the form
e_ digits or e-__ digits.
.sp
.ti -3
(_ expression )_
.br
Parentheses are used to alter normal order of evaluation.
.sp
.ti -3
expression operator expression
.br
Common functions of two arguments are abbreviated
by the two arguments separated by an operator denoting the function.
A complete list of operators is given below.
.sp
.ti -3
expression (_ [expression [,_ expression ...]] )_
.br
Functions of an arbitrary number of arguments
can be called by an expression followed by the arguments
in parentheses separated by commas.
The expression evaluates to the
line number of the entry of the function in the
internally stored statements.
This causes the internal statements to be compiled.
If the expression evaluates negative,
a builtin function is called.
The list of builtin functions appears below.
.sp
.ti -3
name [_ expression [,_ expression ...] ]_
.br
Each expression is truncated to an integer
and used as a specifier for the name.
The result is syntactically identical to a name.
a[1,2] is the same as a[1][2].
The truncated expressions are restricted to 
values between 0 and 32767.
.sp
.ti -6
The following is the list of operators:
.sp
.ti -3
=
.br
= is the assignment operator.
The left operand must be a name or an array element.
The result is the right operand.
Assignment binds right to left,
all other operators bind left to right.
.sp
.ti -3
& |
.br
&_ (logical and)
has result zero if either of its arguments are zero.
It has result one if both its arguments are non-zero.
|_ (logical or)
has result zero if both of its arguments are zero.
It has result one if either of its arguments are non-zero.
.sp
.ti -3
< <= > >= == <>
.br
The relational operators
(< less than, <= less than or equal,
> greater than,
>= greater than or equal,
== equal to,
<> not equal to)
return one if their arguments are in the specified
relation.
They return zero otherwise.
Relational operators at the same level extend as follows:
a>b>c is the same as a>b&b>c.
.sp
.ti -3
+ -
.br
Add and subtract.
.sp
.ti -3
* /
.br
Multiply and divide.
.sp
.ti -3
^
.br
Exponentiation.
.sp
.ti -6
The following is a list of builtin functions:
.sp
.ti -3
arg
.br
Arg(i) is the value of the i_th
actual parameter on the current level
of function call.
.sp
.ti -3
exp
.br
Exp(x) is the exponential function of x.
.sp
.ti -3
log
.br
Log(x) is the logarithm base e of x.
.sp
.ti -3
sin
.br
Sin(x) is the sine of x (radians).
.sp
.ti -3
cos
.br
Cos(x) is the cosine of x (radians).
.sp
.ti -3
atn
.br
Atn(x) is the arctangent of x.
.sp
.ti -3
rnd
.br
Rnd() is a uniformly distributed random
number between zero and one.
.sp
.ti -3
expr
.br
Expr() is the only form of program input.
A line is read from the input and
evaluated as an expression.
The resultant value is returned.
.sp
.ti -3
int
.br
Int(x) returns x truncated to an integer.
.in -6
.sp
.ti 0
FILES		/tmp/btm?	temporary
.sp
.ti 0
SEE ALSO	[1] DEC-11-AJPB-D
.sp
.ti 0
DIAGNOSTICS	Syntax
errors cause the incorrect line to be typed
with an underscore where the parse failed.
All other diagnostics are self explanatory.
.sp
.ti 0
BUGS		--
