Annotation of researchv10dc/dist/man/v4/man1/bas.1, revision 1.1.1.1

1.1       root        1: .th BAS I 1/15/73
                      2: .sh NAME
                      3: bas \*- basic
                      4: .sh SYNOPSIS
                      5: .bd bas
                      6: [ file ]
                      7: .sh DESCRIPTION
                      8: .it Bas
                      9: is a dialect of Basic.
                     10: If a file argument is provided,
                     11: the file is used for input before the console
                     12: is read.
                     13: .it Bas
                     14: accepts lines of the form:
                     15: .s3
                     16:    statement
                     17:    integer statement
                     18: .s3
                     19: Integer numbered statements
                     20: (known as internal statements)
                     21: are stored for later execution.
                     22: They are stored in sorted ascending order.
                     23: Non-numbered statements are immediately executed.
                     24: The result of an immediate expression statement
                     25: (that does not have `=' as its highest operator) is printed.
                     26: .s3
                     27: Statements have the following syntax:
                     28: .s3
                     29: .lp +5 5
                     30: expression
                     31: .br
                     32: The expression is executed for its side
                     33: effects (assignment or function call)
                     34: or for printing as described above.
                     35: .s3
                     36: .lp +5 5
                     37: .bd done
                     38: .br
                     39: Return to system level.
                     40: .s3
                     41: .lp +5 5
                     42: .bd draw
                     43: expression expression expression
                     44: .br
                     45: A line is drawn on the Tektronix 611 display
                     46: `/dev/vt0'
                     47: from
                     48: the current display position
                     49: to the XY co-ordinates specified by the
                     50: first two expressions.
                     51: The scale is zero to one in both X and Y directions.
                     52: If the third expression
                     53: is zero, the line is invisible.
                     54: The current display position is set to the end point.
                     55: .s3
                     56: .lp +5 5
                     57: .bd display
                     58: list
                     59: .br
                     60: The list of expressions and strings is
                     61: concatenated and displayed (i.e. printed) on the 611 starting
                     62: at the current display position.
                     63: The current display position is not changed.
                     64: .s3
                     65: .lp +5 5
                     66: .bd erase
                     67: .br
                     68: The 611 screen is erased.
                     69: .s3
                     70: .lp +5 5
                     71: .bd for
                     72: name
                     73: .bd =
                     74: expression expression statement
                     75: .br
                     76: .lp +5 5
                     77: .bd for
                     78: name
                     79: .bd =
                     80: expression expression
                     81: .br
                     82: .li
                     83: ...
                     84: .lp +5 5
                     85: .bd next
                     86: .br
                     87: The
                     88: .it for
                     89: statement
                     90: repetitively executes a
                     91: statement (first form)
                     92: or a group of statements (second form)
                     93: under control of a named variable.
                     94: The variable takes on the value of
                     95: the first expression,
                     96: then is incremented by one on each loop,
                     97: not to exceed the value of
                     98: the second expression.
                     99: .s3
                    100: .lp +5 5
                    101: .bd goto
                    102: expression
                    103: .br
                    104: The expression is evaluated, truncated to an integer
                    105: and execution goes to the corresponding integer numbered statment.
                    106: If executed from immediate mode,
                    107: the internal statements are compiled first.
                    108: .s3
                    109: .lp +5 5
                    110: .bd if
                    111: expression statement
                    112: .br
                    113: The statement is executed if the expression evaluates
                    114: to non-zero.
                    115: .s3
                    116: .lp +5 5
                    117: .bd list
                    118: [expression [expression]]
                    119: .br
                    120: .br list
                    121: is used to print out the stored internal statements.
                    122: If no arguments are given, all internal statements are printed.
                    123: If one argument is given, only that
                    124: internal statement is listed.
                    125: If two arguments are given, all internal statements
                    126: inclusively between the arguments are printed.
                    127: .s3
                    128: .lp +5 5
                    129: .bd print
                    130: list
                    131: .br
                    132: The list of expressions and strings are concatenated and
                    133: printed.
                    134: (A string is delimited by " characters.)
                    135: .s3
                    136: .lp +5 5
                    137: .bd return
                    138: [expression]
                    139: .br
                    140: The expression is evaluated and the result is passed
                    141: back as the value of a function call.
                    142: If no expression is given, zero is returned.
                    143: .s3
                    144: .lp +5 5
                    145: .bd run
                    146: .br
                    147: The internal statements are compiled.
                    148: The symbol table is re-initialized.
                    149: The random number generator is reset.
                    150: Control is passed to the lowest numbered internal
                    151: statement.
                    152: .s3
                    153: .i0
                    154: Expressions have the following syntax:
                    155: .s3
                    156: .lp +5 5
                    157: name
                    158: .br
                    159: A name is used to specify a variable.
                    160: Names are composed of a letter
                    161: followed by letters and digits.
                    162: The first four characters of a name are significant.
                    163: .s3
                    164: .lp +5 5
                    165: number
                    166: .br
                    167: A number is used to represent a constant value.
                    168: A number is written in Fortran style,
                    169: and contains digits, an optional decimal point,
                    170: and possibly a scale factor consisting
                    171: of an \fBe\fR followed by a possibly signed exponent.
                    172: .s3
                    173: .lp +5 5
                    174: .bd (
                    175: expression
                    176: .bd )
                    177: .br
                    178: Parentheses are used to alter normal order of evaluation.
                    179: .s3
                    180: .lp +5 5
                    181: expression operator expression
                    182: .br
                    183: Common functions of two arguments are abbreviated
                    184: by the two arguments separated by an operator denoting the function.
                    185: A complete list of operators is given below.
                    186: .s3
                    187: .lp +5 5
                    188: expression
                    189: .bd (
                    190: [expression [
                    191: .bd ,
                    192: expression] ... ]
                    193: .bd )
                    194: .br
                    195: Functions of an arbitrary number of arguments
                    196: can be called by an expression followed by the arguments
                    197: in parentheses separated by commas.
                    198: The expression evaluates to the
                    199: line number of the entry of the function in the
                    200: internally stored statements.
                    201: This causes the internal statements to be compiled.
                    202: If the expression evaluates negative,
                    203: a builtin function is called.
                    204: The list of builtin functions appears below.
                    205: .s3
                    206: .lp +5 5
                    207: name
                    208: .bd [
                    209: expression
                    210: [
                    211: .bd ,
                    212: expression
                    213: ] ...
                    214: .bd ]
                    215: .br
                    216: Each expression is truncated to an integer
                    217: and used as a specifier for the name.
                    218: The result is syntactically identical to a name.
                    219: .bd a[1,2]
                    220: is the same as
                    221: .bd a[1][2].
                    222: The truncated expressions are restricted to 
                    223: values between 0 and 32767.
                    224: .s3
                    225: .i0
                    226: The following is the list of operators:
                    227: .s3
                    228: .lp +5 5
                    229: =
                    230: .br
                    231: =
                    232: is the assignment operator.
                    233: The left operand must be a name or an array element.
                    234: The result is the right operand.
                    235: Assignment binds right to left,
                    236: all other operators bind left to right.
                    237: .s3
                    238: .lp +5 5
                    239: &  \*v
                    240: .br
                    241: &
                    242: (logical and)
                    243: has result zero if either of its arguments are zero.
                    244: It has result one if both its arguments are non-zero.
                    245: \*v
                    246: (logical or)
                    247: has result zero if both of its arguments are zero.
                    248: It has result one if either of its arguments are non-zero.
                    249: .s3
                    250: .lp +5 5
                    251: <  <=  >  >=  ==  <>
                    252: .br
                    253: The relational operators
                    254: (< less than, <= less than or equal,
                    255: > greater than,
                    256: >= greater than or equal,
                    257: == equal to,
                    258: <> not equal to)
                    259: return one if their arguments are in the specified
                    260: relation.
                    261: They return zero otherwise.
                    262: Relational operators at the same level extend as follows:
                    263: a>b>c is the same as a>b&b>c.
                    264: .s3
                    265: .lp +5 5
                    266: + \*-
                    267: .br
                    268: Add and subtract.
                    269: .s3
                    270: .lp +5 5
                    271: * /
                    272: .br
                    273: Multiply and divide.
                    274: .s3
                    275: .lp +5 5
                    276: ^
                    277: .br
                    278: Exponentiation.
                    279: .s3
                    280: .i0
                    281: The following is a list of builtin functions:
                    282: .s3
                    283: .lp +5 5
                    284: .bd arg(i)
                    285: .br
                    286: is the value of the
                    287: \fIi\fR|-th
                    288: actual parameter on the current level
                    289: of function call.
                    290: .s3
                    291: .lp +5 5
                    292: .bd exp(x)
                    293: .br
                    294: is the exponential function of \fIx\fR.
                    295: .s3
                    296: .lp +5 5
                    297: .bd log(x)
                    298: .br
                    299: is the natural logarithm of \fIx\fR.
                    300: .s3
                    301: .lp +5 5
                    302: .bd sin(x)
                    303: .br
                    304: is the sine of \fIx\fR (radians).
                    305: .s3
                    306: .lp +5 5
                    307: .bd cos(x)
                    308: .br
                    309: is the cosine of \fIx\fR (radians).
                    310: .s3
                    311: .lp +5 5
                    312: .bd atn(x)
                    313: .br
                    314: is the arctangent of \fIx\fR . its value
                    315: is between \*-\(*p/2 and \(*p/2.
                    316: .s3
                    317: .lp +5 5
                    318: .bd "rnd( )"
                    319: .br
                    320: is a uniformly distributed random
                    321: number between zero and one.
                    322: .s3
                    323: .lp +5 5
                    324: .bd "expr( )"
                    325: .br
                    326: is the only form of program input.
                    327: A line is read from the input and
                    328: evaluated as an expression.
                    329: The resultant value is returned.
                    330: .s3
                    331: .lp +5 5
                    332: .bd int(x)
                    333: .br
                    334: returns \fIx\fR truncated to an integer.
                    335: .i0
                    336: .sh FILES
                    337: .dt
                    338: /tmp/btm?      temporary
                    339: .sh DIAGNOSTICS
                    340: Syntax
                    341: errors cause the incorrect line to be typed
                    342: with an underscore where the parse failed.
                    343: All other diagnostics are self explanatory.
                    344: .sh BUGS
                    345: Has been known to give core images.
                    346: Needs a way to
                    347: .it list
                    348: a program onto a file.

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.