


      BBBBSSSS((((1111))))                       ((((UUUUNNNNIIIIXXXX 5555....0000))))                      BBBBSSSS((((1111))))



      NNNNAAAAMMMMEEEE
           bs - a compiler/interpreter for modest-sized programs

      SSSSYYYYNNNNTTTTAAAAXXXX
           bbbbssss [ file [ args ] ]

      DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
           _B_s is a remote descendant of Basic and Snobol4 with a little
           C language thrown in.  _B_s is designed for programming tasks
           where program development time is as important as the
           resulting speed of execution.  Formalities of data
           declaration and file/process manipulation are minimized.
           Line-at-a-time debugging, the _t_r_a_c_e and _d_u_m_p statements, and
           useful run-time error messages all simplify program testing.
           Furthermore, incomplete programs can be debugged; _i_n_n_e_r
           functions can be tested before _o_u_t_e_r functions have been
           written and vice versa.

           If the command line _f_i_l_e argument is provided, the file is
           used for input before the console is read.  By default,
           statements read from the file argument are compiled for
           later execution.  Likewise, statements entered from the
           console are normally executed immediately (see _c_o_m_p_i_l_e and
           _e_x_e_c_u_t_e below).  Unless the final operation is assignment,
           the result of an immediate expression statement is printed.

           _B_s programs are made up of input lines.  If the last
           character on a line is a \\\\, the line is continued.  _B_s
           accepts lines of the following form:

                statement
                label  statement

           A label is a _n_a_m_e (see below) followed by a colon.  A label
           and a variable can have the same name.

           A _b_s statement is either an expression or a keyword followed
           by zero or more expressions.  Some keywords (_c_l_e_a_r, _c_o_m_p_i_l_e,
           !, _e_x_e_c_u_t_e, _i_n_c_l_u_d_e, _i_b_a_s_e, _o_b_a_s_e, and _r_u_n) are always
           executed as they are compiled.

           SSSSttttaaaatttteeeemmmmeeeennnntttt SSSSyyyynnnnttttaaaaxxxx::::

           expression
              The expression is executed for its side effects (value,
              assignment or function call).  The details of expressions
              follow the description of statement types below.

           bbbbrrrreeeeaaaakkkk
              _B_r_e_a_k exits from the inner-most _f_o_r/_w_h_i_l_e loop.

           cccclllleeeeaaaarrrr



      Page 1                                                   (9010-E)






      BBBBSSSS((((1111))))                       ((((UUUUNNNNIIIIXXXX 5555....0000))))                      BBBBSSSS((((1111))))



              Clears the symbol table and compiled statements.  _C_l_e_a_r
              is executed immediately.

           ccccoooommmmppppiiiilllleeee [ expression ]
              Succeeding statements are compiled (overrides the
              immediate execution default).  The optional expression is
              evaluated and used as a file name for further input.  A
              _c_l_e_a_r is associated with this latter case.  _C_o_m_p_i_l_e is
              executed immediately.

           ccccoooonnnnttttiiiinnnnuuuueeee
              _C_o_n_t_i_n_u_e transfers to the loop-continuation of the
              current _f_o_r/_w_h_i_l_e loop.

           dddduuuummmmpppp [ name ]
              The name and current value of every non-local variable is
              printed.  Optionally, only the named variable is
              reported.  After an error or interrupt, the number of the
              last statement and (possibly) the user-function trace are
              displayed.

           eeeexxxxiiiitttt [ expression ]
              Return to system level.  The expression is returned as
              process status.

           eeeexxxxeeeeccccuuuutttteeee
              Change to immediate execution mode (an interrupt has a
              similar effect).  This statement does not cause stored
              statements to execute (see _r_u_n below).

           ffffoooorrrr name ==== expression expression statement
           ffffoooorrrr name ==== expression expression
              ...
           nnnneeeexxxxtttt

           ffffoooorrrr expression ,,,, expression ,,,, expression  statement
           ffffoooorrrr expression ,,,, expression ,,,, expression
              ...
           nnnneeeexxxxtttt
              The _f_o_r 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.  The third and fourth forms require three
              expressions separated by commas.  The first of these is
              the initialization, the second is the test (true to
              continue), and the third is the loop-continuation action
              (normally an increment).

           ffffuuuunnnn f([a, ... ]) [v, ... ]
              ...



      Page 2                                                   (9010-E)






      BBBBSSSS((((1111))))                       ((((UUUUNNNNIIIIXXXX 5555....0000))))                      BBBBSSSS((((1111))))



           nnnnuuuuffff
              _F_u_n defines the function name, arguments, and local
              variables for a user-written function.  Up to ten
              arguments and local variables are allowed.  Such names
              cannot be arrays, nor can they be I/O associated.
              Function definitions may not be nested.

           ffffrrrreeeettttuuuurrrrnnnn
              A way to signal the failure of a user-written function.
              See the interrogation operator (????) below.  If
              interrogation is not present, _f_r_e_t_u_r_n merely returns
              zero.  When interrogation _i_s active, _f_r_e_t_u_r_n transfers to
              that expression (possibly by-passing intermediate
              function returns).

           ggggoooottttoooo name
              Control is passed to the internally stored statement with
              the matching label.

           iiiibbbbaaaasssseeee _N
              _I_b_a_s_e sets the input base (radix) to _N.  The only
              supported values for _N are 8888, 11110000 (the default), and 11116666.
              Hexadecimal values 10-15 are entered as aaaa-ffff.  A leading
              digit is required (i.e., ffff0000aaaa must be entered as 0000ffff0000aaaa).
              _I_b_a_s_e (and _o_b_a_s_e, below) are executed immediately.

           iiiiffff expression statement
           iiiiffff expression
              ...
           [ eeeellllsssseeee
              ...  ]
           ffffiiii
              The statement (first form) or group of statements (second
              form) is executed if the expression evaluates to non-
              zero.  The strings 0000 and "" (null) evaluate as zero.  In
              the second form, an optional _e_l_s_e allows for a group of
              statements to be executed when the first group is not.
              The only statement permitted on the same line with an
              _e_l_s_e is an _i_f; only other _f_i's can be on the same line
              with a _f_i.  The elision of _e_l_s_e and _i_f into an _e_l_i_f is
              supported.  Only a single _f_i is required to close an _i_f
              ... _e_l_i_f ... [ _e_l_s_e ... ] sequence.

           iiiinnnncccclllluuuuddddeeee expression
              The expression must evaluate to a file name.  The file
              must contain _b_s source statements.  Such statements
              become part of the program being compiled.  _I_n_c_l_u_d_e
              statements may not be nested.

           oooobbbbaaaasssseeee _N
              _O_b_a_s_e sets the output base to _N (see _i_b_a_s_e above).




      Page 3                                                   (9010-E)






      BBBBSSSS((((1111))))                       ((((UUUUNNNNIIIIXXXX 5555....0000))))                      BBBBSSSS((((1111))))



           oooonnnniiiinnnnttttrrrr label
           oooonnnniiiinnnnttttrrrr
              The _o_n_i_n_t_r command provides program control of
              interrupts.  In the first form, control will pass to the
              label given, just as if a _g_o_t_o had been executed at the
              time _o_n_i_n_t_r was executed.  The effect of the statement is
              cleared after each interrupt.  In the second form, an
              interrupt will cause _b_s to terminate.

           rrrreeeettttuuuurrrrnnnn [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.

           rrrruuuunnnn
              The random number generator is reset.  Control is passed
              to the first internal statement.  If the _r_u_n statement is
              contained in a file, it should be the last statement.

           ssssttttoooopppp
              Execution of internal statements is stopped.  _B_s reverts
              to immediate mode.

           ttttrrrraaaacccceeee [ expression ]
              The _t_r_a_c_e statement controls function tracing.  If the
              expression is null (or evaluates to zero), tracing is
              turned off.  Otherwise, a record of user-function
              calls/returns will be printed.  Each _r_e_t_u_r_n decrements
              the _t_r_a_c_e expression value.

           wwwwhhhhiiiilllleeee expression  statement
           wwwwhhhhiiiilllleeee expression
              ...
           nnnneeeexxxxtttt
              _W_h_i_l_e is similar to _f_o_r except that only the conditional
              expression for loop-continuation is given.

           !!!! shell command
              An immediate escape to the Shell.

           #### ...
              This statement is ignored.  It interjects commentary in a
              program.

           EEEExxxxpppprrrreeeessssssssiiiioooonnnn SSSSyyyynnnnttttaaaaxxxx::::

           name
              A name is used to specify a variable.  Names are composed
              of a letter (upper or lower case) optionally followed by
              letters and digits.  Only the first six characters of a
              name are significant.  Except for names declared in _f_u_n
              statements, all names are global to the program.  Names



      Page 4                                                   (9010-E)






      BBBBSSSS((((1111))))                       ((((UUUUNNNNIIIIXXXX 5555....0000))))                      BBBBSSSS((((1111))))



              can take on numeric (double float) values, string values,
              or can be associated with input/output (see the built-in
              function _o_p_e_n() below).

           name (((( [expression [ ,,,, expression] ... ] ))))
              Functions can be called by a name followed by the
              arguments in parentheses separated by commas.  Except for
              built-in functions (listed below), the name must be
              defined with a _f_u_n statement.  Arguments to functions are
              passed by value.

           name [[[[ expression [ ,,,, expression ] ...  ]]]]
              This syntax is used to reference either arrays or tables
              (see built-in _t_a_b_l_e functions below).  For arrays, each
              expression is truncated to an integer and used as a
              specifier for the name.  The resulting array reference is
              syntactically identical to a name; aaaa[[[[1111,,,,2222]]]] is the same as
              aaaa[[[[1111]]]][[[[2222]]]].  The truncated expressions are restricted to
              values between 0 and 32767.

           number
              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 eeee followed by a possibly signed
              exponent.

           string
              Character strings are delimited by """" characters.  The \\\\
              escape character allows the double quote (\\\\""""), new-line
              (\\\\nnnn), carriage return (\\\\rrrr), backspace (\\\\bbbb), and tab (\\\\tttt)
              characters to appear in a string.  Otherwise, \\\\ stands
              for itself.

           (((( expression ))))
              Parentheses are used to alter the normal order of
              evaluation.

           (((( expression,,,, expression [,,,, expression ... ] )))) [[[[ expression
              ]]]]
              The bracketed expression is used as a subscript to select
              a comma-separated expression from the parenthesized list.
              List elements are numbered from the left, starting at
              zero.  The expression:

                     ( False, True )[ a == b ]

              has the value TTTTrrrruuuueeee if the comparison is true.

           ???? expression
              The interrogation operator tests for the success of the
              expression rather than its value.  At the moment, it is



      Page 5                                                   (9010-E)






      BBBBSSSS((((1111))))                       ((((UUUUNNNNIIIIXXXX 5555....0000))))                      BBBBSSSS((((1111))))



              useful for testing end-of-file (see examples in the
              _P_r_o_g_r_a_m_m_i_n_g _T_i_p_s section below), the result of the _e_v_a_l
              built-in function, and for checking the return from
              user-written functions (see _f_r_e_t_u_r_n).  An interrogation
              ``trap'' (end-of-file, etc.) causes an immediate transfer
              to the most recent interrogation, possibly skipping
              assignment statements or intervening function levels.

           ---- expression
              The result is the negation of the expression.

           ++++++++ name
              Increments the value of the variable (or array
              reference).  The result is the new value.

           -------- name
              Decrements the value of the variable.  The result is the
              new value.

           !!!! expression
              The logical negation of the expression.  Watch out for
              the shell escape command.

           expression _o_p_e_r_a_t_o_r expression
              Common functions of two arguments are abbreviated by the
              two arguments separated by an operator denoting the
              function.  Except for the assignment, concatenation, and
              relational operators, both operands are converted to
              numeric form before the function is applied.

           BBBBiiiinnnnaaaarrrryyyy OOOOppppeeeerrrraaaattttoooorrrrssss (in increasing precedence):

           ====
              ==== 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.

           ____
              ____ (underscore) is the concatenation operator.

           &&&&  ||||
              &&&& (logical and) has result zero if either of its
              arguments are zero.  It has result one if both of 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 is non-zero.  Both operators
              treat a null string as a zero.

           <<<<  <<<<====  >>>>  >>>>====  ========  !!!!====
              The relational operators (<<<< less than, <<<<==== less than or
              equal, >>>> greater than, >>>>==== greater than or equal, ======== equal



      Page 6                                                   (9010-E)






      BBBBSSSS((((1111))))                       ((((UUUUNNNNIIIIXXXX 5555....0000))))                      BBBBSSSS((((1111))))



              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.  A string comparison is
              made if both operands are strings.

           ++++  ----
              Add and subtract.

           ****  ////  %%%%
              Multiply, divide, and remainder.

           ^^^^
              Exponentiation.

           BBBBuuuuiiiilllltttt----iiiinnnn FFFFuuuunnnnccccttttiiiioooonnnnssss::::

                           _D_e_a_l_i_n_g _w_i_t_h _a_r_g_u_m_e_n_t_s

           aaaarrrrgggg((((iiii))))
              is the value of the _i-th actual parameter on the current
              level of function call.  At level zero, _a_r_g returns the
              _i-th command-line argument (_a_r_g(0) returns bbbbssss).

           nnnnaaaarrrrgggg(((())))
              returns the number of arguments passed.  At level zero,
              the command argument count is returned.

                                _M_a_t_h_e_m_a_t_i_c_a_l

           aaaabbbbssss((((xxxx))))
              is the absolute value of _x.

           aaaattttaaaannnn((((xxxx))))
              is the arctangent of _x.  Its value is between -J/2 and
              J/2.

           cccceeeeiiiillll((((xxxx))))
              returns the smallest integer not less than _x.

           ccccoooossss((((xxxx))))
              is the cosine of _x (radians).

           eeeexxxxpppp((((xxxx))))
              is the exponential function of _x.

           fffflllloooooooorrrr((((xxxx))))
              returns the largest integer not greater than _x.

           lllloooogggg((((xxxx))))
              is the natural logarithm of _x.




      Page 7                                                   (9010-E)






      BBBBSSSS((((1111))))                       ((((UUUUNNNNIIIIXXXX 5555....0000))))                      BBBBSSSS((((1111))))



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

           ssssiiiinnnn((((xxxx))))
              is the sine of _x (radians).

           ssssqqqqrrrrtttt((((xxxx))))
              is the square root of _x.

                              _S_t_r_i_n_g _o_p_e_r_a_t_i_o_n_s

           ssssiiiizzzzeeee((((ssss))))
              the size (length in bytes) of _s is returned.

           ffffoooorrrrmmmmaaaatttt((((ffff,,,, aaaa))))
              returns the formatted value of _a.  _F is assumed to be a
              format specification in the style of _p_r_i_n_t_f(3S).  Only
              the %%%%............ffff, %%%%............eeee, and %%%%............ssss types are safe.

           iiiinnnnddddeeeexxxx((((xxxx,,,, yyyy))))
              returns the number of the first position in _x that any of
              the characters from _y matches.  No match yields zero.

           ttttrrrraaaannnnssss((((ssss,,,, ffff,,,, tttt))))
              Translates characters of the source _s from matching
              characters in _f to a character in the same position in _t.
              Source characters that do not appear in _f are copied to
              the result.  If the string _f is longer than _t, source
              characters that match in the excess portion of _f do not
              appear in the result.

           ssssuuuubbbbssssttttrrrr((((ssss,,,, ssssttttaaaarrrrtttt,,,, wwwwiiiiddddtttthhhh))))
              returns the sub-string of _s defined by the _s_t_a_r_ting
              position and _w_i_d_t_h.

           mmmmaaaattttcccchhhh((((ssssttttrrrriiiinnnngggg,,,, ppppaaaatttttttteeeerrrrnnnn))))
           mmmmssssttttrrrriiiinnnngggg((((nnnn))))
              The _p_a_t_t_e_r_n is similar to the regular expression syntax
              of the _e_d(1) command.  The characters ...., [[[[, ]]]], ^^^^ (inside
              brackets), **** and $$$$ are special.  The _m_s_t_r_i_n_g function
              returns the _n-th (1 <= _n <= 10) substring of the subject
              that occurred between pairs of the pattern symbols \\\\(((( and
              \\\\)))) for the most recent call to _m_a_t_c_h.  To succeed,
              patterns must match the beginning of the string (as if
              all patterns began with ^^^^).  The function returns the
              number of characters matched.  For example:

                     match("a123ab123", ".*\([a-z]\)") == 6
                     mstring(1) == "b"

                                _F_i_l_e _h_a_n_d_l_i_n_g



      Page 8                                                   (9010-E)






      BBBBSSSS((((1111))))                       ((((UUUUNNNNIIIIXXXX 5555....0000))))                      BBBBSSSS((((1111))))



           ooooppppeeeennnn((((nnnnaaaammmmeeee,,,, ffffiiiilllleeee,,,, ffffuuuunnnnccccttttiiiioooonnnn))))
           cccclllloooosssseeee((((nnnnaaaammmmeeee))))
              The _n_a_m_e argument must be a _b_s variable name (passed as a
              string).  For the _o_p_e_n, the _f_i_l_e argument may be 1111)))) a 0
              (zero), 1, or 2 representing standard input, output, or
              error output, respectively, 2222)))) a string representing a
              file name, or 3333)))) a string beginning with an !!!!
              representing a command to be executed (via _s_h -_c).  The
              _f_u_n_c_t_i_o_n argument must be either rrrr (read), wwww (write), WWWW
              (write without new-line), or aaaa (append).  After a _c_l_o_s_e,
              the _n_a_m_e reverts to being an ordinary variable.  The
              initial associations are:

                     open("get", 0, "r")
                     open("put", 1, "w")
                     open("puterr", 2, "w")

              Examples are given in the following section.

           aaaacccccccceeeessssssss((((ssss,,,, mmmm))))
              executes _a_c_c_e_s_s(2).

           ffffttttyyyyppppeeee((((ssss))))
              returns a single character file type indication:  ffff for
              regular file, dddd for directory, bbbb for block special, or cccc
              for character special.

                                   _T_a_b_l_e_s

           ttttaaaabbbblllleeee((((nnnnaaaammmmeeee,,,, ssssiiiizzzzeeee))))
              A table in _b_s is an associatively accessed, single-
              dimension array.  ``Subscripts'' (called keys) are
              strings (numbers are converted).  The _n_a_m_e argument must
              be a _b_s variable name (passed as a string).  The _s_i_z_e
              argument sets the minimum number of elements to be
              allocated.  _B_s prints an error message and stops on table
              overflow.

           iiiitttteeeemmmm((((nnnnaaaammmmeeee,,,, iiii))))

           kkkkeeeeyyyy(((())))
              The _i_t_e_m function accesses table elements sequentially
              (in normal use, there is no orderly progression of key
              values).  Where the _i_t_e_m function accesses values, the
              _k_e_y function accesses the ``subscript'' of the previous
              _i_t_e_m call.  The _n_a_m_e argument should not be quoted.
              Since exact table sizes are not defined, the
              interrogation operator should be used to detect end-of-
              table, for example:

                     table("t", 100)
                      ...



      Page 9                                                   (9010-E)






      BBBBSSSS((((1111))))                       ((((UUUUNNNNIIIIXXXX 5555....0000))))                      BBBBSSSS((((1111))))



                     # If _w_o_r_d contains "party", the following
                     expression adds one
                     # to the count of that word:
                     ++t[word]
                      ...
                     # To print out the the key/value pairs:
                     for i = 0, ?(s = item(t, i)), ++i   if key()  put
                     = key()_":"_s

           iiiisssskkkkeeeeyyyy((((nnnnaaaammmmeeee,,,, wwwwoooorrrrdddd ))))
              The _i_s_k_e_y function tests whether the key wwwwoooorrrrdddd exists in
              the table nnnnaaaammmmeeee and returns one for true, zero for false.

                                _O_d_d_s _a_n_d _e_n_d_s

           eeeevvvvaaaallll((((ssss))))
              The string argument is evaluated as a _b_s expression.  The
              function is handy for converting numeric strings to
              numeric internal form.  _E_v_a_l can also be used as a crude
              form of indirection, as in:

                     name = "xyz"
                     eval("++"_ name)

              which increments the variable _x_y_z.  In addition, _e_v_a_l
              preceded by the interrogation operator permits the user
              to control _b_s error conditions.  For example:

                     ?eval("open(\"X\", \"XXX\", \"r\")")

              returns the value zero if there is no file named ``XXX''
              (instead of halting the user's program).  The following
              executes a _g_o_t_o to the label _L (if it exists):

                     label="L"
                     if !(?eval("goto "_ label)) puterr = "no label"

           ppppllllooootttt((((rrrreeeeqqqquuuueeeesssstttt,,,, aaaarrrrggggssss))))
              The _p_l_o_t function produces output on devices recognized
              by _t_p_l_o_t(1G).  The _r_e_q_u_e_s_t_s are as follows:

                  _C_a_l_l                                     _F_u_n_c_t_i_o_n

                  plot(0, term)               causes further _p_l_o_t
                                              output to be piped into
                                              _t_p_l_o_t(1G) with an
                                              argument of ----TTTT_t_e_r_m.

                  plot(4)                     ``erases'' the plotter.

                  plot(2, string)             labels the current point
                                              with _s_t_r_i_n_g.



      Page 10                                                  (9010-E)






      BBBBSSSS((((1111))))                       ((((UUUUNNNNIIIIXXXX 5555....0000))))                      BBBBSSSS((((1111))))



                  plot(3, x1, y1, x2, y2)     draws the line between
                                              (_x_1,_y_1) and (_x_2,_y_2).

                  plot(4, x, y, r)            draws a circle with
                                              center (_x,_y) and radius
                                              _r.

                  plot(5, x1, y1, x2, y2, x3, y3)
                                              draws an arc
                                              (counterclockwise) with
                                              center (_x_1,_y_1) and
                                              endpoints (_x_2,_y_2) and
                                              (_x_3,_y_3).

                  plot(6)                     is not implemented.

                  plot(7, x, y)               makes the current point
                                              (_x,_y).

                  plot(8, x, y)               draws a line from the
                                              current point to (_x,_y).

                  plot(9, x, y)               draws a point at (_x,_y).

                  plot(10, string)            sets the line mode to
                                              _s_t_r_i_n_g.

                  plot(11, x1, y1, x2, y2)    makes (_x_1,_y_1) the lower
                                              left corner of the
                                              plotting area and (_x_2,_y_2)
                                              the upper right corner of
                                              the plotting area.

                  plot(12, x1, y1, x2, y2)    causes subsequent x (y)
                                              coordinates to be
                                              multiplied by _x_1 (_y_1) and
                                              then added to _x_2 (_y_2)
                                              before they are plotted.
                                              The initial scaling is
                                              ppppllllooootttt((((11112222,,,, 1111....0000,,,, 1111....0000,,,, 0000....0000,,,,
                                              0000....0000)))).

              Some requests do not apply to all plotters.  All requests
              except zero and twelve are implemented by piping
              characters to _t_p_l_o_t(1G).  See _p_l_o_t(4) for more details.

           llllaaaasssstttt(((())))
              in immediate mode, _l_a_s_t returns the most recently
              computed value.

      PPPPRRRROOOOGGGGRRRRAAAAMMMMMMMMIIIINNNNGGGG TTTTIIIIPPPPSSSS
           Using _b_s as a calculator:



      Page 11                                                  (9010-E)






      BBBBSSSS((((1111))))                       ((((UUUUNNNNIIIIXXXX 5555....0000))))                      BBBBSSSS((((1111))))



                $ bs
                #    Distance (inches) light travels in a nanosecond.
                186000 * 5280 * 12 / 1e9
                11111111....77778888444499996666
                ...

                #    Compound interest (6% for 5 years on $1,000).
                int = .06 / 4
                bal = 1000
                for i = 1 5*4  bal = bal + bal*int
                bal - 1000
                333344446666....888855555555000000007777
                ...
                exit

           The outline of a typical _b_s program:

                # initialize things:
                var1 = 1
                open("read", "infile", "r")
                ...
                # compute:
                while  ?(str = read)
                     ...
                next
                # clean up:
                close("read")
                ...
                # last statement executed (exit or stop):
                exit
                # last input line:
                run

           Input/Output examples:

                #    Copy "oldfile" to "newfile".
                open("read", "oldfile", "r")
                open("write", "newfile", "w")
                ...
                while ?(write = read)
                ...
                # close "read" and "write":
                close("read")
                close("write")

                #    Pipe between commands.
                open("ls", "!ls *", "r")
                open("pr", "!pr -2 -h 'List'", "w")
                while ?(pr = ls)  ...
                ...
                # be sure to close (wait for) these:
                close("ls")



      Page 12                                                  (9010-E)






      BBBBSSSS((((1111))))                       ((((UUUUNNNNIIIIXXXX 5555....0000))))                      BBBBSSSS((((1111))))



                close("pr")

      SSSSEEEEEEEE AAAALLLLSSSSOOOO
           ed(1), sh(1), tplot(1G), access(2), printf(3S), stdio(3S),
           plot(4).
           See Section 3 of this volume for further description of the
           mathematical functions (_p_o_w on _e_x_p(3M) is used for
           exponentiation); _b_s uses the Standard Input/Output package.















































      Page 13                                                  (9010-E)



