basic.doc 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854
  1. .\" $Header$
  2. .TL
  3. .de Sy
  4. .LP
  5. .IP \fBsyntax\fR 10
  6. ..
  7. .de PU
  8. .IP \fBpurpose\fR 10
  9. ..
  10. .de RM
  11. .IP \fBremarks\fR 10
  12. ..
  13. The ABC compiler
  14. .AU
  15. Martin L. Kersten
  16. .AI
  17. Department of Mathematics and Computer Science.
  18. .br
  19. Vrije Universiteit
  20. .AB
  21. This manual describes the
  22. programming language BASIC and its compiler
  23. included in the Amsterdam Compiler Kit.
  24. .AE
  25. .SH
  26. INTRODUCTION.
  27. .LP
  28. The BASIC-EM compiler is an extensive implementation of the
  29. programming language BASIC.
  30. The language structure and semantics are modelled after the
  31. BASIC interpreter/compiler of Microsoft (tr), a detailed comparison
  32. is provided in appendix A.
  33. .LP
  34. The compiler generates code for a virtual machine, the EM machine
  35. [[ACM, etc]]
  36. Using EM as an intermediate machine results in a highly portable
  37. compiler and BASIC code.
  38. The drawback of EM is that it does not directly reflect one particular
  39. hardware design, which means that many of
  40. the low level operations available within
  41. BASIC are ill-defined or even inapplicable.
  42. To mention a few, the peek and poke instructions are likely
  43. to be behave errorneous, while line printer and tapedeck
  44. primitives are unknown.
  45. .LP
  46. This manual is divided into three chapters.
  47. The first chapter discusses the general language syntax and semantics.
  48. Chapter two describes the statements available in BASIC-EM.
  49. Chapter 3 describes the predefined functions,
  50. ordered alphabetically.
  51. Appendix A discusses the differences with
  52. Microsoft BASIC. Appendix B describes all reserved symbols.
  53. Appendix C lists the error messages in use.
  54. .sp
  55. Additional information about EM and the Amsterdam Compiler Kit
  56. can be obtained from .... and found in ......
  57. .SH
  58. SyNTAX NOTATION
  59. .LP
  60. The conventions for syntax presentation are as follows:
  61. .IP CAPS 10
  62. Items are reserved words, must be input as shown
  63. .IP <> 10
  64. Items in lowercase letters enclosed in angular brackets
  65. are to be supplied by the user.
  66. .IP [] 10
  67. Items are optional.
  68. .IP \.\.\. 10
  69. Items may be repeated any number of times
  70. .IP {} 10
  71. A choice between two or more alternatives. At least one of the entries
  72. must be chosen.
  73. .IP | 10
  74. Vertical bars separate the choices within braces.
  75. .LP
  76. All punctuation must be included where shown.
  77. .NH 1
  78. GENERAL INFORMATION
  79. .LP
  80. The BASIC-EM compiler is designed for a UNIX based environment.
  81. It accepts a text file with your BASIC program (suffix .b) and generates
  82. an executable file, called a.out.
  83. .LP
  84. Should we call the preprocessor first?
  85. .NH 2
  86. LINE FORMAT
  87. .LP
  88. A BASIC program consists of a series of lines, starting with a
  89. positive line number in the range 0 to 65529.
  90. A line may consists of more then one physical line on your terminal, but must
  91. is limited to 1024 characters.
  92. Multiple BASIC statements may be placed on a single line, provided
  93. they are separated by a colon (:).
  94. .NH 2
  95. CONSTANTS
  96. .LP
  97. The BASIC compiler character set is comprised of alphabetic
  98. characters, numeric characters, and special characters shown below.
  99. .DS
  100. = + - * / ^ ( ) % # $ \\ _
  101. ! [ ] , . ; : & ' ? > < \\ (blanc)
  102. .DE
  103. .LP
  104. BASIC uses two different types of constants during processing:
  105. numeric and string constants.
  106. .br
  107. A string constant is a sequence of characters taken from the ASCII
  108. character set enclosed by double quotation marks.
  109. .br
  110. Numeric constants are positive or negative numbers, grouped into
  111. five different classes.
  112. .IP "a) integer constants" 25
  113. Whole numbers in the range of -32768 and 32767. Integer constants do
  114. not contain decimal points.
  115. .IP "b) fixed point constants" 25
  116. Positive or negative real numbers, i.e. numbers with a decimal point.
  117. .IP "c) floating point constants" 25
  118. Real numbers in scientific notation. A floating point constant
  119. consists of an optional signed integer or fixed point number
  120. followed by the letter E (or D) and an optional signed integer
  121. (the exponent).
  122. The allowable range of floating point constants is 10^-38 to 10^+38.
  123. .IP "d) Hex constants" 25
  124. Hexadecimal numbers, denoted by the prefix &H.
  125. .IP "d) Octal constants" 25
  126. Octal numbers, denoted by the prefix &O.
  127. .NH 2
  128. VARIABLES
  129. .LP
  130. Variables are names used to represent values in a BASIC program.
  131. A variable is assigned a value by assigment specified in the program.
  132. Before a variable is assigned its value is assumed to be zero.
  133. .br
  134. Variable names are composed of letters, digits or the decimal point,
  135. starting with a letter. Up to 40 characters are significant.
  136. A variable name be be followed by any of the following type
  137. declaration characters:
  138. .IP % 5
  139. Defines an integer variable
  140. .IP ! 5
  141. Defines a single precision variable (see below)
  142. .IP # 5
  143. Defines a double precision variable
  144. .IP $ 5
  145. Defines a string variable.
  146. .LP
  147. NOTE: Two variables with the same name but different type is
  148. considered illegal (DONE?).
  149. .LP
  150. Beside single valued variables, values may be grouped
  151. into tables or arrays.
  152. Each element in an array is referenced by the array name and an index,
  153. such a variable is called a subscripted variable.
  154. An array has as many subscripts as there are dimensions in the array,
  155. the maximum of which is 11.
  156. .br
  157. If a variable starts with FN it is assumed to be a call to a user defined
  158. function.
  159. .br
  160. A variable name may not be a reserved word nor the name
  161. of a predefined function.
  162. A list of all reserved identifiers is included as Appendix ?.
  163. .NH 2
  164. EXPRESSIONS
  165. .LP
  166. BASIC-EM differs from Microsoft BASIC in supporting floats in one precision
  167. only (due to EM).
  168. All floating point constants have the same precision, i.e. 16 digits.
  169. .LP
  170. When necessary the compiler will convert a numeric value from
  171. one type to another.
  172. A value is always converted to the precision of the variable it is assigned
  173. to.
  174. When a floating point value is converted to an integer the fractional
  175. portion is rounded.
  176. In an expression all values are converted to the same degree of precision,
  177. i.e. that of the most precise operand.
  178. .br
  179. Division by zero results in the message "Division by zero".
  180. If overflow (or underflow) occurs, the "Overflow (underflow)" message is
  181. displayed and execution is terminated (contrary to Microsoft).
  182. .SH
  183. Arithmetic
  184. .LP
  185. The arithmetic operators in order of precedence,a re:
  186. .DS L
  187. \^ Exponentiation
  188. - Negation
  189. *,/,\\,MOD Multiplication, Division, Remainder
  190. +,- Addition, Substraction
  191. .DE
  192. The operator \\\\ denotes integer division, its operands are rounded to
  193. integers before the operator is applied.
  194. Modulus arithmetic is denoted by the operator MOD, which yields the
  195. integer value that is the remainder of an integer division.
  196. .br
  197. The order in which operators are performed can be changec with parentheses.
  198. .SH
  199. Relational
  200. .LP
  201. The relational operators in order of precedence, are:
  202. .DS
  203. = Equality
  204. <> Inequality
  205. < Less than
  206. > Greater than
  207. <= Less than or equal to
  208. >= Greater than or equal to
  209. .DE
  210. The relational operators are used to compare two values and returns
  211. either "true" (-1) or "false" (0) (See IF statement).
  212. The precedence of the relational operators is lower
  213. then the arithmetic operators.
  214. .SH
  215. Logical
  216. .LP
  217. The logical operators performs tests on multiple relations, bit manipulations,
  218. or Boolean operations.
  219. The logical operators returns a bitwise result ("true" or "false").
  220. In an expression, logical operators are performed after the relational and
  221. arithmetic operators.
  222. The logical operators work by converting their operands to signed
  223. two-complement integers in the range -32768 to 32767.
  224. .DS
  225. NOT Bitwise negation
  226. AND Bitwise and
  227. OR Bitwise or
  228. XOR Bitwise exclusive or
  229. EQV Bitwise equivalence
  230. IMP Bitwise implies
  231. .DE
  232. .SH
  233. Functional
  234. .LP
  235. A function is used in an expression to call a system or user defined
  236. function.
  237. A list of predefined functions is presented in chapter 3.
  238. .SH
  239. String operations
  240. .LP
  241. Strings can be concatenated by using +. Strings can be compared with
  242. the relational operators. String comparison is performed in lexicographic
  243. order.
  244. .NH 2
  245. ERROR MESSAGES
  246. .LP
  247. The occurence of an error results in termination of the program
  248. unless an ON....ERROR statement has been encountered.
  249. .NH 1
  250. B-EM STATEMENTS
  251. .LP
  252. This chapter describes the statements available within the BASIC-EM
  253. compiler. Each description is formatted as follows:
  254. .Sy
  255. Shows the correct syntax for the statement. See introduction of
  256. syntax notation above.
  257. .PU
  258. Describes the purpose and details of the instructions.
  259. .RM
  260. Describes special cases, deviation from Microsoft BASIC etc.
  261. .LP
  262. .NH 2
  263. CALL
  264. .Sy
  265. CALL <variable name>[(<argument list>)]
  266. .PU
  267. The CALL statement provides the means to execute procedures
  268. and functions written in another language included in the
  269. Amsterdam Compiler Kit.
  270. The argument list consist of (subscripted) variables.
  271. The BASIC compiler pushes the address of the arguments on the stack in order
  272. of encounter.
  273. .RM
  274. Not yet available
  275. .NH 2
  276. CLOSE
  277. .Sy
  278. CLOSE [[#]<file number>[,[#]<file number...>]]
  279. .PU
  280. To terminate I/O on a disk file.
  281. <file number> is the number associated with the file
  282. when it was OPENed (See OPEN). Ommission of parameters results in closing
  283. all files.
  284. .sp
  285. The END statement and STOP statement always issue a CLOSE of
  286. all files.
  287. .NH 2
  288. DATA
  289. .Sy
  290. DATA <list of constants>
  291. .PU
  292. DATA statements are used to construct a data bank of values that are
  293. accessed by the program's READ statement.
  294. DATA statements are non-executable,
  295. the data items are assembled in a data file by the BASIC compiler.
  296. This file can be replaced, provided the layout remains
  297. the same (otherwise the RESTORE won't function properly).
  298. .sp
  299. The list of data items consists of numeric and string constants
  300. as discussed in section 1.
  301. Moreover, string constants starting with a letter and not
  302. containing blancs, newlines, commas, colon need not be enclosed with
  303. the string quotes.
  304. .sp
  305. DATA statements can be reread using the RESTORE statement.
  306. .NH 2
  307. DEF FN
  308. .Sy
  309. DEF FN<name> [(<parameterlist>)]=<expression>
  310. .PU
  311. To define and name a function that is written by the user.
  312. <name> must be an identifier and should be preceded by FN,
  313. which is considered integral part of the function name.
  314. <expression> defines the expression to be evaluated upon function call.
  315. .sp
  316. The parameter list is comprised of a comma separated
  317. list of variable names, used within the function definition,
  318. that are to replaced by values upon function call.
  319. The variable names defined in the parameterlist, called formal
  320. parameters, do not affect the definition and use of variables
  321. defined with the same name in the rest of the BASIC program.
  322. .sp
  323. A type declaration character may be suffixed to the function name to
  324. designate the data type of the function result.
  325. .NH 2
  326. DEFINT/SNG/DBL/STR
  327. .Sy
  328. DEF<type> <range of letters>
  329. .PU
  330. Any undefined variable starting with the letter included in the range of
  331. letters is declared of type <type> unless a type declaration character
  332. is appended.
  333. The range of letters is a comma separated list of characters and
  334. character ranges (<letter>-<letter>).
  335. .NH 2
  336. DIM
  337. .Sy
  338. DIM <list of subscripted variable>
  339. .PU
  340. The DIM statement allocates storage for subscripted variables.
  341. If an undefined subscripted variable is used
  342. the maximum value of the array subscript(s) is assumed to be 10.
  343. A subscript out of range is signalled by the program (when RCK works)
  344. The minimum subscript value is 0, unless the OPTION BASE statement has been
  345. encountered.
  346. .sp
  347. All variables in a subscripted variable are initially zero.
  348. .sp
  349. BUG. Multi-dimensional arrays MUST be defined.
  350. .NH 2
  351. END
  352. .Sy
  353. END
  354. .PU
  355. END terminates a BASIC program and returns to the UNIX shell.
  356. An END statement at the end of the BASIC program is optional.
  357. .NH 2
  358. ERR and ERL
  359. .PU
  360. Whenever an error occurs the variable ERR contains the
  361. error number and ERL the BASIC line where the error occurred.
  362. The variables are usually used in error handling routines
  363. provided by the user.
  364. .NH 2
  365. ERROR
  366. .Sy
  367. ERROR <integer expression>
  368. .PU
  369. To simulate the occurrence of a BASIC error.
  370. To define your own error code use a value not already in
  371. use by the BASIC runtime system.
  372. The list of error messages currently in use
  373. can be found in appendix B.
  374. .NH 2
  375. FIELD
  376. .PU
  377. To be implemented.
  378. .NH 2
  379. FOR...NEXT
  380. .Sy
  381. FOR <variable>= <low>TO<high>[STEP<size>]
  382. .br
  383. ......
  384. .br
  385. NEXT [<variable>][,<variable>...]
  386. .PU
  387. The FOR statements allows a series of statements to be performed
  388. repeatedly. <variable> is used as a counter. During the first
  389. execution pass it is assigned the value <low>,
  390. an arithmetic expression. After each pass the counter
  391. is incremented with the step size <size>, an expression.
  392. Ommission of the step size is intepreted as an increment of 1.
  393. Execution of the program lines specified between the FOR and the NEXT
  394. statement is terminated as soon as <low> is greater than <high>
  395. .sp
  396. The NEXT statement is labeled with the name(s) of the counter to be
  397. incremented.
  398. .sp
  399. The body of the FOR statement is skipped when the initial value of the
  400. loop times the sign of the step exceeds the value of the highest value
  401. times the sign of the step.
  402. .sp
  403. The variables mentioned in the NEXT statement may be ommitted, in which case
  404. the variable of increment the counter of the most recent FOR statement.
  405. If a NEXT statement is encountered before its corresponding FOR statement,
  406. the error message "NEXT without FOR" is generated.
  407. .NH 2
  408. GET
  409. .Sy
  410. GET [#]<file number>[, <record number>]
  411. .PU
  412. To be implemented.
  413. .NH 2
  414. GOSUB...RETURN
  415. .Sy
  416. GOSUB <line number
  417. ...
  418. .br
  419. RETURN
  420. .PU
  421. The GOSUB statement branches to the first statement of a subroutine.
  422. The RETURN statement cause a branch back to the statement following the
  423. most recent GOSUB statement.
  424. A subroutine may contain more than one RETURN statement.
  425. .sp
  426. Subroutines may be called recursively.
  427. Nesting of subroutine calls is limited, upon exceeding the maximum depth
  428. the error message "XXXXX" is displayed.
  429. .NH 2
  430. GOTO
  431. .Sy
  432. GOTO <line number>
  433. .PU
  434. To branch unconditionally to a specified line in the program.
  435. If <line number> does not exists, the compilation error message
  436. "Line not defined" is displayed.
  437. .RM
  438. Microsoft BASIC continues at the first line
  439. equal or greater then the line specified.
  440. .NH 2
  441. IF...THEN
  442. .Sy
  443. .br
  444. IF <expression> THEN {<statements>|<line number>}
  445. [ELSE {<statements>|<line number>}]
  446. .br
  447. .Sy
  448. IF <expression> GOTO <line number>
  449. [ELSE {<statements>|<line number>}]
  450. .PU
  451. The IF statement is used
  452. to make a decision regarding the program flow based on the
  453. result of the expressions.
  454. If the expression is not zero, the THEN or GOTO clause is
  455. executed. If the result of <expression> is zero, the THEN or
  456. GOTO clause is ignored and the ELSE clause, if present is
  457. executed.
  458. .br
  459. IF..THEN..ELSE statements may be nested.
  460. Nesting is limited by the length of the line.
  461. The ELSE clause matches with the closests unmatched THEN.
  462. .sp
  463. When using IF to test equality for a value that is the
  464. result of a floating point expression, remember that the
  465. internal representation of the value may not be exact.
  466. Therefore, the test should be against a range to
  467. handle the relative error.
  468. .RM
  469. Microsoft BASIC allows a comma before THEN.
  470. .NH 2
  471. INPUT
  472. .Sy
  473. INPUT [;][<"prompt string">;]<list of variables>
  474. .PU
  475. An INPUT statement can be used to obtain values from the user at the
  476. terminal.
  477. When an INPUT statement is encountered a question mark is printed
  478. to indicate the program is awaiting data.
  479. IF <"prompt string"> is included, the string is printed before the
  480. the question mark. The question mark is suppressed when the prompt
  481. string is followed by a comma, rather then a semicolon.
  482. .sp
  483. For each variable in the variable a list a value should be supplied.
  484. Data items presented should be separated by a comma.
  485. .sp
  486. The type of the variable in the variable list must aggree with the
  487. type of the data item entered. Responding with too few or too many
  488. data items causes the message "?Redo". No assignment of input values
  489. is made until an acceptable response is given.
  490. .RM
  491. The option to disgard the carriage return with the semicolon after the
  492. input symbol is not yet implemented.
  493. .NH 2
  494. INPUT [#]
  495. .Sy
  496. INPUT #<file number>,<list of variables>
  497. .PU
  498. The purpose of the INPUT# statement is to read data items from a sequential
  499. file and assign them to program variables.
  500. <file number> is the number used to open the file for input.
  501. The variables mentioned are (subscripted) variables.
  502. The type of the data items read should aggree with the type of the variables.
  503. A type mismatch results in the error message "XXXXX".
  504. .sp
  505. The data items on the sequential file are separated by commas and newlines.
  506. In scanning the file, leading spaces, new lines, tabs, and
  507. carriage returns are ignored. The first character encountered
  508. is assumed to be the state of a new item.
  509. String items need not be enclosed with double quotes, provided
  510. it does not contain spaces, tabs, newlines and commas,
  511. .RM
  512. Microsoft BASIC won't assign values until the end of input statement.
  513. This means that the user has to supply all the information.
  514. .NH 2
  515. LET
  516. .Sy
  517. [LET]<variable>=<expression>
  518. .PU
  519. To assign the value of an expression to a (subscribted) variable.
  520. The type convertions as dictated in section 1.X apply.
  521. .NH 2
  522. LINE INPUT
  523. .Sy
  524. LINE INPUT [;][<"prompt string">;]<string variable>
  525. .PU
  526. An entire line of input is assigned to the string variable.
  527. See INPUT for the meaning of the <"prompt string"> option.
  528. .NH 2
  529. LINE INPUT [#]
  530. .Sy
  531. LINE INPUT #<file number>,<string variable>
  532. .PU
  533. Read an entire line of text from a sequential file <file number>
  534. and assign it to a string variable.
  535. .NH 2
  536. LSET and RSET
  537. .PU
  538. To be implemented
  539. .NH 2
  540. MID$
  541. .Sy
  542. MID$(<string expr1>,n[,m])=<string expr2>
  543. .PU
  544. To replace a portion of a string with another string value.
  545. The characters of <string expr> replaces characters in <string expr1>
  546. starting at position n. If m is present, at most m characters are copied,
  547. otherwise all characters are copied.
  548. However, the string obtained never exceeds the length of string expr1.
  549. .NH 2
  550. ON ERROR GOTO
  551. .Sy
  552. ON ERROR GOTO <line number>
  553. .PU
  554. To enable error handling within the BASIC program.
  555. An error may result from arithmetic errors, disk problems, interrupts, or
  556. as a result of the ERROR statement.
  557. After printing an error message the program is continued at the
  558. statements associated with <line number>.
  559. .sp
  560. Error handling is disabled using ON ERROR GOTO 0.
  561. Subsequent errors result in an error message and program termination.
  562. .NH 2
  563. ON...GOSUB and ON ...GOTO
  564. .Sy
  565. ON <expression> GOSUB <list of line numbers>
  566. ON <expression> GOTO <list of line numbers>
  567. .PU
  568. To branch to one of several specified line numbers or subroutines, based
  569. on the result of the <expression>. The list of line numbers are considered
  570. the first, second, etc alternative. Branching to the first occurs when
  571. the expression evaluates to one, to the second alternative on two, etc.
  572. If the value of the expression in zero or greater than the number of alternatives, processing continues at the first statement following the ON..GOTO
  573. (ON GOSUB) statement.
  574. When the expression results in a negative number the
  575. an "Illegal function call" error occurs.
  576. .NH 2
  577. OPEN
  578. .NH 2
  579. OPTION BASE
  580. .Sy
  581. OPTION BASE n
  582. .PU
  583. To declare the lower bound of subsequent array subscripts as either
  584. 0 or 1. The default lower bound is zero.
  585. .NH 2
  586. POKE
  587. .Sy
  588. POKE <expr1>,<expr2>
  589. .PU
  590. To poke around in memory. The use of this statement is not recommended,
  591. because it requires full understanding of both
  592. the implementation of the Amsterdam
  593. Compiler Kit and the hardware characteristics.
  594. .NH 2
  595. PRINT [USING]
  596. .NH 2
  597. PUT
  598. .PU
  599. To be implemented
  600. .NH 2
  601. RANDOMIZE
  602. .Sy
  603. RANDOMIZE [<expression>]
  604. .PU
  605. To reset the random seed. When the expression is ommitted, the system
  606. will ask for a value between -32768 and 32767.
  607. The random number generator returns the same sequence of values provided
  608. the same seed is used.
  609. .NH 2
  610. READ
  611. .Sy
  612. READ <list of variables>
  613. .PU
  614. To read values from the DATA statements and assign them to variables.
  615. The type of the variables should match to the type of the items being read,
  616. otherwise a "Syntax error" occurs.
  617. .NH 2
  618. REM
  619. .Sy
  620. REM <remark>
  621. .PU
  622. To include explantory information in a program.
  623. The REM statements are not executed.
  624. A single quote has the same effect as : REM, which
  625. allows for the inclusion of comment at the end of the line.
  626. .RM
  627. Microsoft BASIC does not allow REM statements as part of
  628. DATA lines.
  629. .NH 2
  630. RESTORE
  631. .Sy
  632. RESTORE [<line number>]
  633. .PU
  634. To allow DATA statements to be re-read from a specific line.
  635. After a RESTORE statement is executed, the next READ accesses
  636. the first item of the DATA statements.
  637. If <line number> is specified, the next READ accesses the first
  638. item in the specified line.
  639. .sp
  640. Note that data statements result in a sequential datafile generated
  641. by the compiler, being read by the read statements.
  642. This data file may be replaced using the operating system functions
  643. with a modified version, provided the same layout of items
  644. (same number of lines and items per line) is used.
  645. .NH 2
  646. STOP
  647. .Sy
  648. STOP
  649. .PU
  650. To terminate the execution of a program and return to the operating system
  651. command interpreter. A STOP statement results in the message "Break in line
  652. ???"
  653. .NH 2
  654. SWAP
  655. .Sy
  656. SWAP <variable>,<variable>
  657. .PU
  658. To exchange the values of two variables.
  659. .NH 2
  660. TRON/TROFF
  661. .Sy
  662. TRON
  663. .Sy
  664. TROFF
  665. .PU
  666. As an aid in debugging the TRON statement results in a program
  667. listing each line being interpreted. TROFF disables generation of
  668. this code.
  669. .NH 2
  670. WHILE...WEND
  671. .Sy
  672. WHILE <expression>
  673. .....
  674. WEND
  675. .PU
  676. To execute a series of BASIC statements as long as a conditional expression
  677. is true. WHILE...WEND loops may be nested.
  678. .NH 2
  679. WRITE
  680. .Sy
  681. WRITE [<list of expressions>]
  682. .PU
  683. To write data at the terminal in DATA statement layout conventions.
  684. The expressions should be separated by commas.
  685. .NH 2
  686. WRITE #
  687. .Sy
  688. WRITE #<file number> ,<list of expressions>
  689. .PU
  690. To write a sequential data file, being opened with the "O" mode.
  691. The values are being writting using the DATA statements layout conventions.
  692. .NH
  693. FUNCTIONS
  694. .LP
  695. .IP ABS(X) 12
  696. Returns the absolute value of expression X
  697. .IP ASC(X$) 12
  698. Returns the numeric value of the first character of the string.
  699. If X$ is not initialized an "Illegal function call" error
  700. is returned.
  701. .IP ATN(X) 12
  702. Returns the arctangent of X in radians. Result is in the range
  703. of -pi/2 to pi/2.
  704. .IP CDBL(X) 12
  705. Converts X to a double precision number.
  706. .IP CHR$(X) 12
  707. Converts the integer value X to its ASCII character.
  708. X must be in the range of 0 to 127.
  709. It is used for cursor addressing and generating bel signals.
  710. .IP CINT(X) 12
  711. Converts X to an integer by rounding the fractional portion.
  712. If X is not in the range -32768 to 32767 an "Overflow"
  713. error occurs.
  714. .IP COS(X) 12
  715. Returns the cosine of X in radians.
  716. .IP CSNG(X) 12
  717. Converts X to a double precision number.
  718. .IP CVI(<2-bytes>) 12
  719. Convert two byte string value to integer number.
  720. .IP CVS(<4-bytes>) 12
  721. Convert four byte string value to single precision number.
  722. .IP CVD(<8-bytes>) 12
  723. Convert eight byte string value to double precision number.
  724. .IP EOF[(<file-number>)] 12
  725. Returns -1 (true) if the end of a sequential file has been reached.
  726. .IP EXP(X) 12
  727. Returns e(base of natural logarithm) to the power of X.
  728. X should be less then 10000.0.
  729. .IP FIX(X) 12
  730. Returns the truncated integer part of X. FIX(X) is
  731. equivalent to SGN(X)*INT(ABS(X)).
  732. The major difference between FIX and INT is that FIX does not
  733. return the next lower number for negative X.
  734. .IP HEX$(X) 12
  735. Returns the string which represents the hexadecimal value of
  736. the decimal argument. X is rounded to an integer using CINT
  737. before HEX$ is evaluated.
  738. .IP INT(X) 12
  739. Returns the largest integer <= X.
  740. .IP INPUT$(X[,[#]Y]) 12
  741. Returns the string of X characters read from the terminal or
  742. the designated file.
  743. .IP LEX(X$) 12
  744. Returns the number of characters in the string X$.
  745. Non printable and blancs are counted too.
  746. .IP LOC(<file\ number>) 12
  747. For sequential files LOC returns
  748. position of the read/write head, counted in number of bytes.
  749. For random files the function returns the record number just
  750. read or written from a GET or PUT statement.
  751. If nothing was read or written 0 is returned.
  752. .IP LOG(X) 12
  753. Returns the natural logarithm of X. X must be greater than zero.
  754. .IP MID$(X,I,[J]) 12
  755. To be implemented.
  756. .IP MKI$(X) 12
  757. Converts an integer expression to a two-byte string.
  758. .IP MKS$(X) 12
  759. Converts a single precision expression to a four-byte string.
  760. .IP MKD$(X) 12
  761. Converts a double precision expression to a eight-byte string.
  762. .IP OCT$(X) 12
  763. Returns the string which represents the octal value of the decimal
  764. argument. X is rounded to an integer using CINT before OCTS is evaluated.
  765. .IP PEEK(I) 12
  766. Returns the byte read from the indicated memory. (Of limited use
  767. in the context of ACK)
  768. .IP POS(I) 12
  769. Returns the current cursor position. To be implemented.
  770. .IP RIGHT$(X$,I)
  771. Returns the right most I characters of string X$.
  772. If I=0 then the empty string is returned.
  773. .IP RND(X) 12
  774. Returns a random number between 0 and 1. X is a dummy argument.
  775. .IP SGN(X) 12
  776. If X>0 , SGN(X) returns 1.
  777. .br
  778. if X=0, SGN(X) returns 0.
  779. .br
  780. if X<0, SGN(X) returns -1.
  781. .IP SIN(X) 12
  782. Returns the sine of X in radians.
  783. .IP SPACE$(X) 12
  784. Returns a string of spaces length X. The expression
  785. X is rounded to an integer using CINT.
  786. .IP STR$(X)
  787. Returns the string representation value of X.
  788. .IP STRING$(I,J) 12
  789. Returns thes string of length Iwhose characters all
  790. have ASCII code J. (or first character when J is a string)
  791. .IP TAB(I) 12
  792. Spaces to position I on the terminal. If the current
  793. print position is already beyond space I,TAB
  794. goes to that position on the next line.
  795. Space 1 is leftmost position, and the rightmost position
  796. is width minus 1. To be used within PRINT statements only.
  797. .IP TAN(X) 12
  798. Returns the tangent of X in radians. If TAN overflows
  799. the "Overflow" message is displayed.
  800. .IP VAL(X$) 12
  801. Returns the numerical value of string X$.
  802. The VAL function strips leading blanks and tabs from the
  803. argument string.
  804. .SH
  805. APPENDIX A DIFFERENCES WITH MICROSOFT BASIC
  806. .LP
  807. The following list of Microsoft commands and statements are
  808. not recognized by the compiler.
  809. .DS
  810. SPC
  811. USR
  812. VARPTR
  813. AUTO
  814. CHAIN
  815. CLEAR
  816. CLOAD
  817. COMMON
  818. CONT
  819. CSAVE
  820. DELETE
  821. EDIT
  822. ERASE
  823. FRE
  824. KILL
  825. LIST
  826. LLIST
  827. LOAD
  828. LPRINT
  829. MERGE
  830. NAME
  831. NEW
  832. NULL
  833. RENUM
  834. RESUME
  835. RUN
  836. SAVE
  837. WAIT
  838. WIDTH LPRINT
  839. .DE
  840. Some statements are in the current implementation not available,
  841. but will be soon. These include:
  842. .DS
  843. CALL
  844. DEFUSR
  845. FIELD
  846. GET
  847. INKEY
  848. INPUT$
  849. INSTR$
  850. LEFT$
  851. LSET
  852. RSET
  853. PUT
  854. .DE