1BAS(1)                      General Commands Manual                     BAS(1)
2
3
4

NAME

6       bas - basic
7

SYNOPSIS

9       bas [ file ]
10

DESCRIPTION

12       Bas is a dialect of Basic.  If a file argument is provided, the file is
13       used for input before the terminal is read.  Bas accepts lines  of  the
14       form:
15
16          statement
17          integer statement
18
19       Integer  numbered  statements (known as internal statements) are stored
20       for later execution.  They are stored in sorted ascending order.   Non-
21       numbered statements are immediately executed.  The result of an immedi‐
22       ate expression statement (that does not have `=' as its highest  opera‐
23       tor) is printed.  Interrupts suspend computation.
24
25       Statements have the following syntax:
26
27       expression
28            The  expression  is  executed  for its side effects (assignment or
29            function call) or for printing as described above.
30
31       comment
32            This statement is ignored.  It is used to interject commentary  in
33            a program.
34
35       done
36            Return to system level.
37
38       dump
39            The name and current value of every variable is printed.
40
41       edit
42            The UNIX editor, ed, is invoked with the file argument.  After the
43            editor exits, this file is recompiled.
44
45       for name = expression expression statement
46       for name = expression expression
47       next
48            The for statement repetitively executes a statement  (first  form)
49            or  a  group  of statements (second form) under control of a named
50            variable.  The variable takes on the value of  the  first  expres‐
51            sion,  then  is incremented by one on each loop, not to exceed the
52            value of the second expression.
53
54       goto expression
55            The expression is evaluated, truncated to an integer and execution
56            goes  to the corresponding integer numbered statment.  If executed
57            from immediate mode, the internal statements are compiled first.
58
59       if expression statement
60       if expression
61       [ else
62       fi
63            The statement (first form) or group of statements (second form) is
64            executed  if  the expression evaluates to non-zero.  In the second
65            form, an optional else allows for a group of statements to be exe‐
66            cuted when the first group is not.
67
68       list [expression [expression]]
69            is  used to print out the stored internal statements.  If no argu‐
70            ments are given, all internal  statements  are  printed.   If  one
71            argument is given, only that internal statement is listed.  If two
72            arguments are given, all internal statements  inclusively  between
73            the arguments are printed.
74
75       print list
76            The  list of expressions and strings are concatenated and printed.
77            (A string is delimited by " characters.)
78
79       prompt list
80            Prompt is the same as print except that no  newline  character  is
81            printed.
82
83       return [expression]
84            The  expression  is evaluated and the result is passed back as the
85            value of a function call.  If no  expression  is  given,  zero  is
86            returned.
87
88       run
89            The internal statements are compiled.  The symbol table is re-ini‐
90            tialized.  The random  number  generator  is  reset.   Control  is
91            passed to the lowest numbered internal statement.
92
93       save [expression [expression]]
94            Save  is  like  list except that the output is written on the file
95            argument.  If no argument is given on the command, b.out is used.
96
97       Expressions have the following syntax:
98
99       name
100            A name is used to specify a variable.  Names  are  composed  of  a
101            letter  followed by letters and digits.  The first four characters
102            of a name are significant.
103
104       number
105            A number is used to represent a constant value.  A number is writ‐
106            ten  in  Fortran  style,  and contains digits, an optional decimal
107            point, and possibly a scale factor consisting of an e followed  by
108            a possibly signed exponent.
109
110       ( expression )
111            Parentheses are used to alter normal order of evaluation.
112
113       _ expression
114            The result is the negation of the expression.
115
116       expression operator expression
117            Common functions of two arguments are abbreviated by the two argu‐
118            ments separated by an operator denoting the function.  A  complete
119            list of operators is given below.
120
121       expression ( [expression [ , expression] ... ] )
122            Functions  of an arbitrary number of arguments can be called by an
123            expression followed by the arguments in parentheses  separated  by
124            commas.   The expression evaluates to the line number of the entry
125            of the function in the internally stored statements.  This  causes
126            the  internal statements to be compiled.  If the expression evalu‐
127            ates negative, a builtin function is called.  The list of  builtin
128            functions appears below.
129
130       name [ expression [ , expression ] ...  ]
131            Each expression is truncated to an integer and used as a specifier
132            for the name.  The result is syntactically identical  to  a  name.
133            a[1,2]  is  the  same  as  a[1][2].  The truncated expressions are
134            restricted to values between 0 and 32767.
135
136       The following is the list of operators:
137
138       =      = is the assignment operator.  The left operand must be  a  name
139              or  an array element.  The result is the right operand.  Assign‐
140              ment binds right to left,
141
142       &  |   & (logical and) has result zero if either of its  arguments  are
143              zero.   It has result one if both its arguments are non-zero.  |
144              (logical or) has result zero if both of its arguments are  zero.
145              It has result one if either of its arguments are non-zero.
146
147       <  <=  >  >=  ==  <>
148              The  relational operators (< less than, <= less than or equal, >
149              greater than, >= greater than or equal,  ==  equal  to,  <>  not
150              equal  to)  return  one  if their arguments are in the specified
151              relation.  They return zero otherwise.  Relational operators  at
152              the same level extend as follows: a>b>c is the same as a>b&b>c.
153
154       + -    Add and subtract.
155
156       * /    Multiply and divide.
157
158       ^      Exponentiation.
159
160       The following is a list of builtin functions:
161
162       arg(i) is  the value of the i -th actual parameter on the current level
163              of function call.
164
165       exp(x) is the exponential function of x.
166
167       log(x) is the natural logarithm of x.
168
169       sqr(x) is the square root of x.
170
171       sin(x) is the sine of x (radians).
172
173       cos(x) is the cosine of x (radians).
174
175       atn(x) is the arctangent of x.  Its value is between -π/2 and π/2.
176
177       rnd( ) is a uniformly distributed random number between zero and one.
178
179       expr( )
180              is the only form of program input.  A  line  is  read  from  the
181              input  and  evaluated  as an expression.  The resultant value is
182              returned.
183
184       abs(x) is the absolute value of x.
185
186       int(x) returns x truncated (towards 0) to an integer.
187

FILES

189       /tmp/btm? temporary
190       b.out          save file
191       /bin/ed   for edit
192

DIAGNOSTICS

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

BUGS

198       Has been known to give core images.
199       Catches interrupts even when they are turned off.
200
201
202
203                                                                        BAS(1)
Impressum