home *** CD-ROM | disk | FTP | other *** search
- .th BAS I 5/15/74
- .sh NAME
- bas \*- basic
- .sh SYNOPSIS
- .bd bas
- [ file ]
- .sh DESCRIPTION
- .it Bas
- is a dialect of Basic.
- If a file argument is provided,
- the file is used for input before the console
- is read.
- .it Bas
- accepts lines of the form:
- .s3
- statement
- integer statement
- .s3
- 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.
- .s3
- Statements have the following syntax:
- .s3
- .lp +5 5
- expression
- .br
- The expression is executed for its side
- effects (assignment or function call)
- or for printing as described above.
- .s3
- .lp +5 5
- .bd comment
- .li
- ...
- .br
- This statement is ignored.
- It is used to interject commentary in a program.
- .s3
- .lp +5 5
- .bd done
- .br
- Return to system level.
- .s3
- .lp +5 5
- .bd 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.
- .s3
- .lp +5 5
- .bd 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.
- .s3
- .lp +5 5
- .bd dump
- .br
- The name and current value of every
- variable is printed.
- .s3
- .lp +5 5
- .bd edit
- .br
- The UNIX editor,
- .it ed,
- is invoked with the
- .it file
- argument.
- After the editor exits,
- this file is recompiled.
- .s3
- .lp +5 5
- .bd erase
- .br
- The 611 screen is erased.
- .s3
- .lp +5 5
- .bd for
- name
- .bd =
- expression expression statement
- .br
- .lp +5 5
- .bd for
- name
- .bd =
- expression expression
- .br
- .li
- ...
- .lp +5 5
- .bd next
- .br
- The
- .it 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.
- .s3
- .lp +5 5
- .bd 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.
- .s3
- .lp +5 5
- .bd if
- expression statement
- .br
- .lp +5 5
- .bd if
- expression
- .br
- .li
- ...
- .lp +5 5
- [
- .bd else
- .br
- .li
- ... ]
- .lp +5 5
- .bd fi
- .br
- The statement (first form)
- or group of statements (second form)
- is executed if the expression evaluates
- to non-zero.
- In the second form,
- an optional
- .bd else
- allows for a group of statements to be
- executed when the first group is not.
- .s3
- .lp +5 5
- .bd list
- [expression [expression]]
- .br
- .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.
- .s3
- .lp +5 5
- .bd print
- list
- .br
- The list of expressions and strings are concatenated and
- printed.
- (A string is delimited by " characters.)
- .s3
- .lp +5 5
- .bd prompt
- list
- .br
- .it Prompt
- is the same as
- .it print
- except that no newline character is
- printed.
- .s3
- .lp +5 5
- .bd 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.
- .s3
- .lp +5 5
- .bd run
- .br
- The internal statements are compiled.
- The symbol table is re-initialized.
- The random number generator is reset.
- Control is passed to the lowest numbered internal
- statement.
- .s3
- .lp +5 5
- .bd save
- [expression [expression]]
- .br
- .it Save
- is like
- .it list
- except that the output
- is written on the
- .it file
- argument.
- If no argument is given on the command,
- .bd b.out
- is used.
- .s3
- .i0
- Expressions have the following syntax:
- .s3
- .lp +5 5
- name
- .br
- A name is used to specify a variable.
- Names are composed of a letter
- followed by letters and digits.
- The first four characters of a name are significant.
- .s3
- .lp +5 5
- number
- .br
- A number is used to represent a constant value.
- A number is written in Fortran style,
- and contains digits, an optional decimal point,
- and possibly a scale factor consisting
- of an
- .bd e
- followed by a possibly signed exponent.
- .s3
- .lp +5 5
- .bd (
- expression
- .bd )
- .br
- Parentheses are used to alter normal order of evaluation.
- .s3
- .lp +5 5
- \*_ expression
- .br
- The result is the negation of the expression.
- .s3
- .lp +5 5
- 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.
- .s3
- .lp +5 5
- expression
- .bd (
- [expression [
- .bd ,
- expression] ... ]
- .bd )
- .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.
- .s3
- .lp +5 5
- name
- .bd [
- expression
- [
- .bd ,
- expression
- ] ...
- .bd ]
- .br
- Each expression is truncated to an integer
- and used as a specifier for the name.
- The result is syntactically identical to a name.
- .bd a[1,2]
- is the same as
- .bd a[1][2].
- The truncated expressions are restricted to
- values between 0 and 32767.
- .s3
- .i0
- The following is the list of operators:
- .s3
- .lp +5 5
- =
- .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.
- .s3
- .lp +5 5
- & |
- .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.
- .s3
- .lp +5 5
- < <= > >= == <>
- .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.
- .s3
- .lp +5 5
- + \*-
- .br
- Add and subtract.
- .s3
- .lp +5 5
- * /
- .br
- Multiply and divide.
- .s3
- .lp +5 5
- ^
- .br
- Exponentiation.
- .s3
- .i0
- The following is a list of builtin functions:
- .s3
- .lp +5 5
- .bd arg(i)
- .br
- is the value of the
- \fIi\fR -th
- actual parameter on the current level
- of function call.
- .s3
- .lp +5 5
- .bd exp(x)
- .br
- is the exponential function of \fIx\fR.
- .s3
- .lp +5 5
- .bd log(x)
- .br
- is the natural logarithm of \fIx\fR.
- .s3
- .lp +5 5
- .bd sqr(x)
- .br
- is the square root of \fIx\fR.
- .s3
- .lp +5 5
- .bd sin(x)
- .br
- is the sine of \fIx\fR (radians).
- .s3
- .lp +5 5
- .bd cos(x)
- .br
- is the cosine of \fIx\fR (radians).
- .s3
- .lp +5 5
- .bd atn(x)
- .br
- is the arctangent of \fIx\fR. Its value
- is between \*-\(*p/2 and \(*p/2.
- .s3
- .lp +5 5
- .bd "rnd( )"
- .br
- is a uniformly distributed random
- number between zero and one.
- .s3
- .lp +5 5
- .bd "expr( )"
- .br
- is the only form of program input.
- A line is read from the input and
- evaluated as an expression.
- The resultant value is returned.
- .s3
- .lp +5 5
- .bd abs(x)
- .br
- is the absolute value of \fIx\fR.
- .s3
- .lp +5 5
- .bd int(x)
- .br
- returns \fIx\fR truncated (towards 0) to an integer.
- .i0
- .sh FILES
- .dt
- /tmp/btm? temporary
- .br
- b.out save file
- .sh DIAGNOSTICS
- Syntax
- errors cause the incorrect line to be typed
- with an underscore where the parse failed.
- All other diagnostics are self explanatory.
- .sh BUGS
- Has been known to give core images.
-