man(1) Manual page archive

bas(1) - Unix First Edition Manual Page
11/3/71BAS (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:


statementinteger statement


Integer numbered statements (known as internal statements)are stored for later execution. They are stored in sorted ascending order. Non-- numbered statements are immediatelyexecuted. The result of an immediate expression statement (that does not have `=` as its highest operator) is printed.


Statements have the following syntax: (expr is short forexpression)


expr The expression is executed for its side effects


(assignment or function call) or for printing asdescribed above.


doneReturn to system level. draw expr expr exprdraw is used to draw on a 611--type storage scope


through a TSP--i plotter interface. The coordinates ofthe scope face are zero to one in both the x and y directions. (Zero,zero being the lower left corner.)The expressions are evaluated and design at-- ed X, Y, and Z. A line is drawn from the previous X, Y to the new X, Y * If Z is non--zero, the line is visible,otherwise the line is invisible.


for name = expr expr statementfor name = expr expr


.. . nextThe for statement repetatively 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 isincremented by one on each loop, not to exceed the value of the second expression.


11/3/71BAS (I)



goto expr The expression is evaluated, truncated to an integerand execution goes to the corresponding integer numbered statement. If executed from immediate mode,the internal statements are compiled first.


if expr statementThe statement is executed if the expression


evaluates to non--zero. list [ expr [expr]]list is used to print out the stored internal


statements. If no arguments are given, all internalstatements are printed. If one argument is given, only that internal statement is listed. If two argumentsare given, all internal statements inclusively between the arguments are printed.


print exprThe expression is evaluated and printed.


return exprThe expression is evaluated and the result is passed


back as the value of a function call.


runThe 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. Expressions have the following syntax:


nameA name is used to specify a variable. Names are composed of a letter (`a' -- `z') followed by lettersand digits. The first four characters of a name are significant.


numberA number is used to represent a constant value. A number is composed of digits, at most one decimalpoint ('.') and possibly a scale factor of the form e digits or e-- digits.


( expr )Parentheses are used to alter normal order of evaluation. expr op exprCommon functions of two arguments are


11/3/71BAS (I)



abbreviated by the two arguments separated by anoperator denoting the function. A complete list of operators is given below. expr ( [expr [ , expr ]]Functions of an arbitrary number of arguments can be


called by an expression followed by the arguments inparentheses separated by commas. The expression evaluates to the line number of the entry of thefunction in the internally stored statements. This causes the internal statements to be compiled. If theexpression evaluates negative, an builtin function is called. The list of builtin functions appears below.name [ expr [ , expr ...] ]


Arrays are not yet implemented. The following is the list of operators:


= is the assignment operator. The left operand must bea name or an array element. The result is the right operand. Assignment binds right to left, all otheroperators bind left to right.


& |& (logical and) has result zero if either of its arguments are zero. It has result one if both itsarguments are non--zero. | (logical or) has result zero if both of its arguments are zero. It has resultone 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 arguments are in the specified relation. They returnzero otherwise. Relational operators at the same level extend as follows: a>b>c is the same as a>b&b>c.


+ - Add and subtract.


* /Multiply and divide. ^


Exponeniation.


11/3/71BAS (I)



-The following is a list of builtin functions:


argArg(i) is the value of the ith actual parameter on the current level of function call.


expExp(x) is the exponential function of x.


logLog(x) is the logarithm base of x. sinSin(x) is the sine of x (radians). co sCos(x) is the cosine of x (radians).


atnAtn(x) is the arctangent of x. (Not implemented.)


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


exprExpr() is the only form of program input. A line is read from the input and evaluated as an expression.The resultant value is returned.


intInt(x) returns x truncated to an integer.
FILES /tmp/btma, btmb *.. temporary
SEE_ALSO
DIAGNOSTICS Syntax errors cause the incorrect line to be typed with anunderscore where the parse failed. All other diagnostics are


self explanatory.
BUGS Arrays [] are not yet implemented. In general, programsizes, recursion, etc are not checked, and cause trouble.


OWNER ken