basic.doc 25 KB

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