BAS(I)                       5/15/74                       BAS(I)



NAME
     bas - basic

SYNOPSIS
     bas [ file ]

DESCRIPTION
     Bas  is a dialect of Basic.  If a file argument is provided,
     the file is used for input before the console is read.   Bas
     accepts lines of the form:

        statement
        integer statement

     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.

     Statements have the following syntax:

     expression
          The expression is executed for its  side  effects  (as-
          signment or function call) or for printing as described
          above.

     comment ...
          This statement is ignored.  It  is  used  to  interject
          commentary in a program.

     done
          Return to system level.

     draw expression expression expression
          A line is drawn on the Tektronix 611 display `/dev/vt0'
          from the current display position to  the  XY  co-ordi-
          nates  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.

     display list
          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.

     dump
          The  name and current value of every variable is print-
          ed.

     edit
          The UNIX editor, ed, is invoked with the file argument.
          After the editor exits, this file is recompiled.


                              - 1 -




BAS(I)                       5/15/74                       BAS(I)


     erase
          The 611 screen is erased.

     for name = expression expression statement
     for name = expression expression
          ...
     next
          The  for  statement  repetitively  executes a statement
          (first form) or a group of statements (second form) un-
          der 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.

     goto expression
          The expression is evaluated, truncated  to  an  integer
          and  execution  goes  to the corresponding integer num-
          bered statment.  If executed from immediate  mode,  the
          internal statements are compiled first.

     if expression statement
     if expression
          ...
     [ else
          ... ]
     fi
          The statement (first form) or group of statements (sec-
          ond form) is executed if the  expression  evaluates  to
          non-zero.   In the second form, an optional else allows
          for a group of statements to be executed when the first
          group is not.

     list [expression [expression]]
          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.

     print list
          The list of expressions and  strings  are  concatenated
          and  printed.  (A string is delimited by " characters.)

     prompt list
          Prompt is the same as  print  except  that  no  newline
          character is printed.

     return [expression]
          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.

     run
          The internal statements are compiled.  The symbol table
          is re-initialized.  The random number generator is  re-


                              - 2 -




BAS(I)                       5/15/74                       BAS(I)


          set.  Control is passed to the lowest numbered internal
          statement.

     save [expression [expression]]
          Save is like list except that the output is written  on
          the file argument.  If no argument is given on the com-
          mand, b.out is used.

     Expressions have the following syntax:

     name
          A name is used to specify a variable.  Names  are  com-
          posed  of a letter followed by letters and digits.  The
          first four characters of a name are significant.

     number
          A number is used to represent a constant value.  A num-
          ber  is  written in Fortran style, and contains digits,
          an optional decimal point, and possibly a scale  factor
          consisting  of an e followed by a possibly signed expo-
          nent.

     ( expression )
          Parentheses are used to alter normal order  of  evalua-
          tion.

     _ expression
          The result is the negation of the expression.

     expression operator expression
          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.

     expression ( [expression [ , expression] ... ] )
          Functions of an arbitrary number of  arguments  can  be
          called  by  an  expression followed by the arguments in
          parentheses separated by commas.  The expression evalu-
          ates to the line number of the entry of the function in
          the internally stored statements.  This causes the  in-
          ternal  statements  to  be compiled.  If the expression
          evaluates negative, a builtin function is called.   The
          list of builtin functions appears below.

     name [ expression [ , expression ] ...  ]
          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  be-
          tween 0 and 32767.

     The following is the list of operators:

     =
          = is the assignment operator.  The left operand must be
          a name or an array element.  The result  is  the  right


                              - 3 -




BAS(I)                       5/15/74                       BAS(I)


          operand.  Assignment binds right to left, all other op-
          erators bind left to right.

     &  |
          & (logical and) has result zero if either of its  argu-
          ments  are  zero.   It has result one if both its argu-
          ments 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.

     <  <=  >  >=  ==  <>
          The relational operators (< less than, <= less than  or
          equal,  >  greater  than,  >= greater than or equal, ==
          equal to, <> not equal to) return one  if  their  argu-
          ments  are in the specified relation.  They return zero
          otherwise.  Relational operators at the same level  ex-
          tend as follows: a>b>c is the same as a>b&b>c.

     + -
          Add and subtract.

     * /
          Multiply and divide.

     ^
          Exponentiation.

     The following is a list of builtin functions:

     arg(i)
          is  the value of the i -th actual parameter on the cur-
          rent level of function call.

     exp(x)
          is the exponential function of x.

     log(x)
          is the natural logarithm of x.

     sqr(x)
          is the square root of x.

     sin(x)
          is the sine of x (radians).

     cos(x)
          is the cosine of x (radians).

     atn(x)
          is the arctangent of x.  Its value is between  -/2  and
          /2.

     rnd( )
          is  a  uniformly distributed random number between zero
          and one.



                              - 4 -




BAS(I)                       5/15/74                       BAS(I)


     expr( )
          is the only form of program input.  A line is read from
          the  input  and evaluated as an expression.  The resul-
          tant value is returned.

     abs(x)
          is the absolute value of x.

     int(x)
          returns x truncated (towards 0) to an integer.

FILES
     /tmp/btm?       temporary
     b.out           save file

DIAGNOSTICS
     Syntax errors cause the incorrect line to be typed  with  an
     underscore  where  the  parse failed.  All other diagnostics
     are self explanatory.

BUGS
     Has been known to give core images.




































                              - 5 -