home *** CD-ROM | disk | FTP | other *** search
/ minnie.tuhs.org / unixen.tar / unixen / PDP-11 / Trees / V6 / usr / man / man1 / bas.1 < prev    next >
Encoding:
Text File  |  1975-06-26  |  7.7 KB  |  437 lines

  1. .th BAS I 5/15/74
  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 comment
  38. .li
  39. ...
  40. .br
  41. This statement is ignored.
  42. It is used to interject commentary in a program.
  43. .s3
  44. .lp +5 5
  45. .bd done
  46. .br
  47. Return to system level.
  48. .s3
  49. .lp +5 5
  50. .bd draw
  51. expression expression expression
  52. .br
  53. A line is drawn on the Tektronix 611 display
  54. `/dev/vt0'
  55. from
  56. the current display position
  57. to the XY co-ordinates specified by the
  58. first two expressions.
  59. The scale is zero to one in both X and Y directions.
  60. If the third expression
  61. is zero, the line is invisible.
  62. The current display position is set to the end point.
  63. .s3
  64. .lp +5 5
  65. .bd display
  66. list
  67. .br
  68. The list of expressions and strings is
  69. concatenated and displayed (i.e. printed) on the 611 starting
  70. at the current display position.
  71. The current display position is not changed.
  72. .s3
  73. .lp +5 5
  74. .bd dump
  75. .br
  76. The name and current value of every
  77. variable is printed.
  78. .s3
  79. .lp +5 5
  80. .bd edit
  81. .br
  82. The UNIX editor,
  83. .it ed,
  84. is invoked with the
  85. .it file
  86. argument.
  87. After the editor exits,
  88. this file is recompiled.
  89. .s3
  90. .lp +5 5
  91. .bd erase
  92. .br
  93. The 611 screen is erased.
  94. .s3
  95. .lp +5 5
  96. .bd for
  97. name
  98. .bd =
  99. expression expression statement
  100. .br
  101. .lp +5 5
  102. .bd for
  103. name
  104. .bd =
  105. expression expression
  106. .br
  107. .li
  108. ...
  109. .lp +5 5
  110. .bd next
  111. .br
  112. The
  113. .it for
  114. statement
  115. repetitively executes a
  116. statement (first form)
  117. or a group of statements (second form)
  118. under control of a named variable.
  119. The variable takes on the value of
  120. the first expression,
  121. then is incremented by one on each loop,
  122. not to exceed the value of
  123. the second expression.
  124. .s3
  125. .lp +5 5
  126. .bd goto
  127. expression
  128. .br
  129. The expression is evaluated, truncated to an integer
  130. and execution goes to the corresponding integer numbered statment.
  131. If executed from immediate mode,
  132. the internal statements are compiled first.
  133. .s3
  134. .lp +5 5
  135. .bd if
  136. expression statement
  137. .br
  138. .lp +5 5
  139. .bd if
  140. expression
  141. .br
  142. .li
  143. ...
  144. .lp +5 5
  145. [
  146. .bd else
  147. .br
  148. .li
  149. ... ]
  150. .lp +5 5
  151. .bd fi
  152. .br
  153. The statement (first form)
  154. or group of statements (second form)
  155. is executed if the expression evaluates
  156. to non-zero.
  157. In the second form,
  158. an optional
  159. .bd else
  160. allows for a group of statements to be
  161. executed when the first group is not.
  162. .s3
  163. .lp +5 5
  164. .bd list
  165. [expression [expression]]
  166. .br
  167. .br list
  168. is used to print out the stored internal statements.
  169. If no arguments are given, all internal statements are printed.
  170. If one argument is given, only that
  171. internal statement is listed.
  172. If two arguments are given, all internal statements
  173. inclusively between the arguments are printed.
  174. .s3
  175. .lp +5 5
  176. .bd print
  177. list
  178. .br
  179. The list of expressions and strings are concatenated and
  180. printed.
  181. (A string is delimited by " characters.)
  182. .s3
  183. .lp +5 5
  184. .bd prompt
  185. list
  186. .br
  187. .it Prompt 
  188. is the same as
  189. .it print
  190. except that no newline character is
  191. printed.
  192. .s3
  193. .lp +5 5
  194. .bd return
  195. [expression]
  196. .br
  197. The expression is evaluated and the result is passed
  198. back as the value of a function call.
  199. If no expression is given, zero is returned.
  200. .s3
  201. .lp +5 5
  202. .bd run
  203. .br
  204. The internal statements are compiled.
  205. The symbol table is re-initialized.
  206. The random number generator is reset.
  207. Control is passed to the lowest numbered internal
  208. statement.
  209. .s3
  210. .lp +5 5
  211. .bd save
  212. [expression [expression]]
  213. .br
  214. .it Save
  215. is like
  216. .it list
  217. except that the output
  218. is written on the
  219. .it file
  220. argument.
  221. If no argument is given on the command,
  222. .bd b.out
  223. is used.
  224. .s3
  225. .i0
  226. Expressions have the following syntax:
  227. .s3
  228. .lp +5 5
  229. name
  230. .br
  231. A name is used to specify a variable.
  232. Names are composed of a letter
  233. followed by letters and digits.
  234. The first four characters of a name are significant.
  235. .s3
  236. .lp +5 5
  237. number
  238. .br
  239. A number is used to represent a constant value.
  240. A number is written in Fortran style,
  241. and contains digits, an optional decimal point,
  242. and possibly a scale factor consisting
  243. of an
  244. .bd e
  245. followed by a possibly signed exponent.
  246. .s3
  247. .lp +5 5
  248. .bd (
  249. expression
  250. .bd )
  251. .br
  252. Parentheses are used to alter normal order of evaluation.
  253. .s3
  254. .lp +5 5
  255. \*_ expression
  256. .br
  257. The result is the negation of the expression.
  258. .s3
  259. .lp +5 5
  260. expression operator expression
  261. .br
  262. Common functions of two arguments are abbreviated
  263. by the two arguments separated by an operator denoting the function.
  264. A complete list of operators is given below.
  265. .s3
  266. .lp +5 5
  267. expression
  268. .bd (
  269. [expression [
  270. .bd ,
  271. expression] ... ]
  272. .bd )
  273. .br
  274. Functions of an arbitrary number of arguments
  275. can be called by an expression followed by the arguments
  276. in parentheses separated by commas.
  277. The expression evaluates to the
  278. line number of the entry of the function in the
  279. internally stored statements.
  280. This causes the internal statements to be compiled.
  281. If the expression evaluates negative,
  282. a builtin function is called.
  283. The list of builtin functions appears below.
  284. .s3
  285. .lp +5 5
  286. name
  287. .bd [
  288. expression
  289. [
  290. .bd ,
  291. expression
  292. ] ...
  293. .bd ]
  294. .br
  295. Each expression is truncated to an integer
  296. and used as a specifier for the name.
  297. The result is syntactically identical to a name.
  298. .bd a[1,2]
  299. is the same as
  300. .bd a[1][2].
  301. The truncated expressions are restricted to 
  302. values between 0 and 32767.
  303. .s3
  304. .i0
  305. The following is the list of operators:
  306. .s3
  307. .lp +5 5
  308. =
  309. .br
  310. =
  311. is the assignment operator.
  312. The left operand must be a name or an array element.
  313. The result is the right operand.
  314. Assignment binds right to left,
  315. all other operators bind left to right.
  316. .s3
  317. .lp +5 5
  318. &  |
  319. .br
  320. &
  321. (logical and)
  322. has result zero if either of its arguments are zero.
  323. It has result one if both its arguments are non-zero.
  324. |
  325. (logical or)
  326. has result zero if both of its arguments are zero.
  327. It has result one if either of its arguments are non-zero.
  328. .s3
  329. .lp +5 5
  330. <  <=  >  >=  ==  <>
  331. .br
  332. The relational operators
  333. (< less than, <= less than or equal,
  334. > greater than,
  335. >= greater than or equal,
  336. == equal to,
  337. <> not equal to)
  338. return one if their arguments are in the specified
  339. relation.
  340. They return zero otherwise.
  341. Relational operators at the same level extend as follows:
  342. a>b>c is the same as a>b&b>c.
  343. .s3
  344. .lp +5 5
  345. + \*-
  346. .br
  347. Add and subtract.
  348. .s3
  349. .lp +5 5
  350. * /
  351. .br
  352. Multiply and divide.
  353. .s3
  354. .lp +5 5
  355. ^
  356. .br
  357. Exponentiation.
  358. .s3
  359. .i0
  360. The following is a list of builtin functions:
  361. .s3
  362. .lp +5 5
  363. .bd arg(i)
  364. .br
  365. is the value of the
  366. \fIi\fR -th
  367. actual parameter on the current level
  368. of function call.
  369. .s3
  370. .lp +5 5
  371. .bd exp(x)
  372. .br
  373. is the exponential function of \fIx\fR.
  374. .s3
  375. .lp +5 5
  376. .bd log(x)
  377. .br
  378. is the natural logarithm of \fIx\fR.
  379. .s3
  380. .lp +5 5
  381. .bd sqr(x)
  382. .br
  383. is the square root of \fIx\fR.
  384. .s3
  385. .lp +5 5
  386. .bd sin(x)
  387. .br
  388. is the sine of \fIx\fR (radians).
  389. .s3
  390. .lp +5 5
  391. .bd cos(x)
  392. .br
  393. is the cosine of \fIx\fR (radians).
  394. .s3
  395. .lp +5 5
  396. .bd atn(x)
  397. .br
  398. is the arctangent of \fIx\fR.  Its value
  399. is between \*-\(*p/2 and \(*p/2.
  400. .s3
  401. .lp +5 5
  402. .bd "rnd( )"
  403. .br
  404. is a uniformly distributed random
  405. number between zero and one.
  406. .s3
  407. .lp +5 5
  408. .bd "expr( )"
  409. .br
  410. is the only form of program input.
  411. A line is read from the input and
  412. evaluated as an expression.
  413. The resultant value is returned.
  414. .s3
  415. .lp +5 5
  416. .bd abs(x)
  417. .br
  418. is the absolute value of \fIx\fR.
  419. .s3
  420. .lp +5 5
  421. .bd int(x)
  422. .br
  423. returns \fIx\fR truncated (towards 0) to an integer.
  424. .i0
  425. .sh FILES
  426. .dt
  427. /tmp/btm?    temporary
  428. .br
  429. b.out        save file
  430. .sh DIAGNOSTICS
  431. Syntax
  432. errors cause the incorrect line to be typed
  433. with an underscore where the parse failed.
  434. All other diagnostics are self explanatory.
  435. .sh BUGS
  436. Has been known to give core images.
  437.