home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / DRI-archive / roche / PCWPATB.TXT < prev    next >
Internet Message Format  |  2009-12-11  |  16KB

  1. From: "Arobase, Salle multimΘdia" <salle.arob...@wanadoo.fr>
  2. Newsgroups: comp.os.cpm
  3. Subject: Documentation of Palo Alto Tiny BASIC
  4. Date: Sat, 7 Jun 2003 10:28:30 +0200
  5. Organization: Wanadoo, l'internet avec France Telecom
  6. Lines: 484
  7. Message-ID: <bbs7cl$rta$1@news-reader12.wanadoo.fr>
  8. References: <bblb2g$s7v$1@newsg4.svr.pol.co.uk>
  9. Reply-To: "Arobase, Salle multimΘdia" <salle.arob...@wanadoo.fr>
  10. NNTP-Posting-Host: apoitiers-106-2-3-61.w81-248.abo.wanadoo.fr
  11. X-Trace: news-reader12.wanadoo.fr 1054974165 28586 81.248.43.61 (7 Jun 2003 08:22:45 GMT)
  12. X-Complaints-To: abuse@wanadoo.fr
  13. NNTP-Posting-Date: 7 Jun 2003 08:22:45 GMT
  14. X-Priority: 3
  15. X-MSMail-Priority: Normal
  16. X-Newsreader: Microsoft Outlook Express 6.00.2600.0000
  17. X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
  18.  
  19. PCWPATB.TXT
  20. -----------
  21.  
  22. This file was retyped from the "PCC's REFERENCE BOOK", published
  23. in  1977,  by  Emmanuel ROCHE, who ported PATB  to  the  Amstrad
  24. PCW8256 (PCWPATB.ASM) circa 1986...
  25.  
  26.  
  27. Palo Alto Tiny BASIC Version Three  (PATB v3)
  28. ==================================
  29. by LI-CHEN WANG
  30. ---------------
  31.  
  32. Palo  Alto  Tiny BASIC (PATB) is one of the  implementations  of
  33. Tiny BASIC proposed in "People's Computer Company Newspaper" and
  34. "Dr.  DOBB's  Journal".  However,  there  are  some  differences
  35. between the original proposal and PATB.
  36.  
  37.      a) FOR-NEXT loop is implemented in PATB.
  38.  
  39.      b) PRINT format control is implemented in PATB.
  40.  
  41.      c) PATB uses semicolons (";") to separate commands (instead
  42.         of MBASIC's ":") , and commas (",") to separate items in
  43.         the   same   command.   E.g.:   120   INPUT    A,B,C;LET
  44.         D=5,E=7;PRINT F,G,H
  45.  
  46.      d) Compare  operators  can be used in any  expression,  not
  47.         restricted to IF command.
  48.  
  49.      e) PATB  allows  prompt  strings  in  the  INPUT   command.
  50.         Furthermore,  if the input is not valid, the  prompt  is
  51.         automatically repeated until a valid input is keyed in.
  52.  
  53.      f) PATB command keywords may be abbreviated.
  54.  
  55.  
  56. Version  1.0  of  PATB was published  in  "Dr.  DOBB's  Journal"
  57. (Vol.1,  No.5).  Version 2.0 was published  in  "Interface  Age"
  58. (Vol.2, No.1). The version presented here (Version 3.0)  differs
  59. from the previous ones in that:
  60.  
  61.      a) The RST instructions are no longer used as CALL's.  This
  62.         makes  the program longer, but enables one  to  relocate
  63.         the  program  to  anywhere in the  address  space.  (RST
  64.         instructions call subroutines on Page Zero.)
  65.  
  66.      b) A  few JMP instructions are inserted, so that  the  user
  67.         can extend PATB by changing these JMP's.
  68.  
  69.      c) Some other small changes in PRINT command.
  70.  
  71.      d) In  Version  1.0, there are two known bugs: FOR  I=1  TO
  72.         32767 will never end, and ABS(-32767-1) gives a negative
  73.         result.  In Version 2.0, there is one known bug:  ABS(0)
  74.         gives an error. These bugs are fixed in Version 3.0.
  75.  
  76.  
  77. THE LANGUAGE
  78. ============
  79.  
  80. NUMBERS
  81. -------
  82.  
  83. All numbers are integers, and must be between -32767 and 32767.
  84.  
  85.  
  86. VARIABLES
  87. ---------
  88.  
  89. There are 26 variables, denoted by letters A through Z. There is
  90. also a single array @(I). The dimension of the array (i.e.,  the
  91. range of values of the index I) is set automatically to make use
  92. of  all  the  memory space that is left unused  by  the  program
  93. (i.e., 0 through SIZE/2, see SIZE function below.)
  94.  
  95.  
  96. FUNCTIONS
  97. ---------
  98.  
  99. Without  extension, there are only 3 functions.  More  functions
  100. can be added as extensions.
  101.  
  102.         ABS(X)  Gives the absolute value of X.
  103.         RND(X)  Gives a random number between 1 and X (inclusive).
  104.         SIZE    Gives the number of bytes left unused by the program.
  105.  
  106.  
  107. ARITHMETIC AND COMPARE OPERATORS
  108. --------------------------------
  109.  
  110.      /  divide. (Note that, since we have integers only, 2/3=0.)
  111.      *  multiply.
  112.      -  subtract.
  113.      +  add.
  114.      >  (compare) greater than.
  115.      <  (compare) less than.
  116.      =  (compare)  equal to. (Note that, to certain versions  of
  117.         BASIC,  'LET  A=B=0' means 'set both A and B to  0'.  To
  118.         this  version  of  Tiny BASIC, it means 'set  A  to  the
  119.         result of comparing B with 0'.)
  120.      #  (compare) not equal to. (MBASIC uses "<>".)
  121.      >= (compare) greater than or equal to.
  122.      <= (compare) less than or equal to.
  123.  
  124. +,  -, *, and / operations result in a value between -32767  and
  125. 32767. (-32768 is also allowed in some cases.) The result of any
  126. comparison is 1 if True, 0 if not True (False).
  127.  
  128.  
  129. EXPRESSIONS
  130. -----------
  131.  
  132. Expressions  are formed with numbers, variables,  and  functions
  133. with  arithmetic  and compare operators between them.  +  and  -
  134. signs  can also be used at the beginning of an  expression.  The
  135. value  of an expression is evaluated from left to right,  except
  136. that  * and / are always done first, + and - next,  and  compare
  137. operators  the last. Parentheses can also be used to  alter  the
  138. order of evaluation.
  139.  
  140.  
  141. STATEMENTS
  142. ----------
  143.  
  144. A  Tiny  BASIC  statement must consist  of  a  statement  number
  145. between 1 and 32767, followed by one or more commands.  Commands
  146. in the same statement are separated by a semi-colon (";"). GOTO,
  147. STOP, and RETURN commands must be the last command in any  given
  148. statement.
  149.  
  150.  
  151. PROGRAM
  152. -------
  153.  
  154. A Tiny BASIC program consists of one or more statements. When  a
  155. direct  command  RUN is issued, the statement  with  the  lowest
  156. statement  number is executed first, then the one with the  next
  157. lowest statement number, etc. However, the GOTO, GOSUB, STOP and
  158. RETURN  commands  can  alter this normal  sequence.  Within  the
  159. statement, execution of the commands is from left to right.  The
  160. IF command can cause the execution of all commands to its  right
  161. in the same statement to be skipped.
  162.  
  163.  
  164. COMMANDS
  165. --------
  166.  
  167. Tiny BASIC commands (unextended) are listed below with examples.
  168. More commands can be added as extensions. Remember that commands
  169. can be concatenated with semicolons (";"). In order to store the
  170. statement, you must also have a statement number in front of the
  171. commands.  The  statement number and the concatenation  are  not
  172. shown in the examples.
  173.  
  174.  
  175. REM or REMARK command
  176. ---------------------
  177.  
  178. REM causes the interpreter to ignore the rest of the line.  This
  179. allows the programmer to put remarks in the program.
  180.  
  181.  
  182. LET command
  183. -----------
  184.  
  185.         LET A=234-5*6, A=A/2, X=A-100, @(X+9)=A-1
  186.  
  187. will  set the variable A to the value of the expression  234-5*6
  188. (i.e.,  204),  set the variable A (again) to the  value  of  the
  189. expression  A/2 (i.e., 102), set the variable X to the value  of
  190. the expression A-100 (i.e., 2), and then set the variable  @(11)
  191. to 101 (where 11 is the value of the expression X+9, and 101  is
  192. the value of the expression A-1).
  193.  
  194.         LET U=A#B, V=(A>B)*X+(A<B)*Y
  195.  
  196. will set the variable U to either 1 or 0, depending on whether A
  197. is  not  equal to or is equal to B, respectively;  and  set  the
  198. variable  V  to  either X, Y or 0, depending  on  whether  A  is
  199. greater than, less than, or equal to B, respectively.
  200.  
  201.  
  202. PRINT command
  203. -------------
  204.  
  205.         PRINT A*3+1, 'AB"123', "#'!@%"
  206.         PRINT A*3+1, 'AB"123', "#'!@%",
  207.  
  208. The  first command will print the value of the expression  A*3+1
  209. (e.g.,  307), the string of characters ABC"123, and  the  string
  210. #'!@%, and then start a new line. Note that either single (') or
  211. double  (") quotes can be used to quote strings, but pairs  must
  212. be matched. The second command (ending with a ",") will  produce
  213. the  same output as the first, except that it will not  start  a
  214. new  line  after  the last item is  printed.  This  enables  the
  215. program to continue printing on the same line with another PRINT
  216. command.
  217.  
  218. Numerical  values are printed with leading blanks, so that  they
  219. take 8 spaces each. This field width can be changed by a #  sign
  220. followed  by  a number indicating the new width. The  new  width
  221. will  be effective until the end of this PRINT  command,  unless
  222. changed  again  by #n. Note that no trailing space  is  printed.
  223. Extra spaces can be generated by repeated commas.
  224.  
  225.         PRINT A, #3, B,,, C+1,
  226.  
  227. This will print the value of A in 8 spaces, the value of B in  3
  228. spaces  (more if B > 999 or B < -99), two extra spaces, and  the
  229. value of C+1 in 3 spaces (more if C > 998 or C < -100).
  230.  
  231.         PRINT ^L, ^K, ^I
  232.  
  233. This  command will print the control characters FF  (Control-L),
  234. VT (Control-K), and HT (Control-I). Control characters can  also
  235. appear  inside  quotes,  but the method  used  here  makes  them
  236. visible in the program listing.
  237.  
  238.  
  239. INPUT command
  240. -------------
  241.  
  242.         INPUT A, B
  243.  
  244. When this command is executed, Tiny BASIC will print A, a space,
  245. and  wait  to  read  in an expression  from  the  keyboard.  The
  246. variable  A  will be set to the value of the  input  expression.
  247. Then  B  is printed with a space, and variable B is set  to  the
  248. value of the next expression read from the keyboard.
  249.  
  250.         INPUT 'WHAT IS YOUR WEIGHT?'A, "YOUR HEIGHT?"B
  251.  
  252. This  is the same as the command above, except the prompt: A  is
  253. replaced by: WHAT IS YOUR WEIGHT?, and the prompt: B is replaced
  254. by:  YOUR HEIGHT?. Again, both single (') and double (")  quotes
  255. can be used, as long as they are matched.
  256.  
  257. In  both of the above examples, if the input (at run time)  from
  258. the keyboard is not a valid expression, Tiny BASIC will  reprint
  259. the  prompt and wait again until a valid expression is  entered.
  260. One may also choose to reprint only part of the prompt, e.g.:
  261.  
  262.         INPUT "WHAT IS ", "YOUR WEIGHT?"A, "YOUR HEIGHT?"B
  263.  
  264. In this case, WHAT IS YOUR WEIGHT? will be asked the first time;
  265. while only the part YOUR WEIGHT? will be repeated if an  invalid
  266. input is given.
  267.  
  268.  
  269. IF command
  270. ----------
  271.  
  272.         IF A<B LET X=3; PRINT 'THIS STRING'
  273.  
  274. will  test  the value of the expression A<B. If it is  not  zero
  275. (i.e.,  if  it  is  True), the commands  in  the  rest  of  this
  276. statement  will be executed. If the value of the  expression  is
  277. zero  (i.e., if it is not True, hence False), the rest  of  this
  278. statement  will be skipped and execution continues at  the  next
  279. statement. Note that the word "THEN" is not used.
  280.  
  281.  
  282. GOTO command
  283. ------------
  284.  
  285.         GOTO 120
  286.  
  287. will  jump to statement 120 and proceed from that statement  on.
  288. Note  that GOTO command cannot be followed by a semicolon  (";")
  289. and  other  commands. It must be ended with a CR. (Be  the  last
  290. command on a line.)
  291.  
  292.         GOTO A*10+B
  293.  
  294. will  jump to a statement number as computed from the  value  of
  295. the expression and proceed from that point on.
  296.  
  297.  
  298. GOSUB and RETURN commands
  299. -------------------------
  300.  
  301. GOSUB  command  is different from GOTO command in that:  a)  the
  302. current  statement number and position within the  statement  is
  303. remembered;  and  b) a semicolon (";") and  other  commands  can
  304. follow GOSUB in the same statement.
  305.  
  306.         GOSUB 120
  307.  
  308. will cause the execution to jump to statement 120.
  309.  
  310.         GOSUB A*10+B
  311.  
  312. will  cause the execution to jump to the statement  as  computed
  313. from the given expression A*10+B.
  314.  
  315.         RETURN
  316.  
  317. A  RETURN  command  must be the last  command  in  a  statement,
  318. followed  by  a  CR. (Be the last command on a  line.)   When  a
  319. RETURN  command is encountered, execution will jump back to  the
  320. command following the most recent GOSUB command.
  321.  
  322. GOSUB  can be nested. The depth of the nest is limited  only  by
  323. the stack space.
  324.  
  325.  
  326. FOR and NEXT commands
  327. ---------------------
  328.  
  329.         FOR X=A+1 TO 3*B STEP C-1
  330.  
  331. The  variable X is set to the value of the expression  A+1.  The
  332. values  of the expressions (not the expressions themselves)  3*B
  333. and  C-1  are  remembered.  The name  of  the  variable  X,  the
  334. statement  number  and the position of this command  within  the
  335. statement  are  also remembered. Execution  then  continues  the
  336. normal sequence until a NEXT command is encountered.
  337.  
  338. The STEP can be positive, negative and even zero. The word  STEP
  339. and  the expression following it can be omitted if  the  desired
  340. STEP is +1.
  341.  
  342.         NEXT X
  343.  
  344. The  name of the variable (X) is checked with that of  the  most
  345. recent FOR command. If they do not agree, that FOR is terminated
  346. and the next recent FOR is checked, etc. When a match is  found,
  347. this variable will be set to its current value plus the value of
  348. the STEP expression saved by the FOR command. The updated  value
  349. is then compared with the value of the TO expression also  saved
  350. by the FOR command. If this is within the limit, execution  will
  351. jump  back to the command following the FOR command. If this  is
  352. outside  the  limit,  execution  continues  following  the  NEXT
  353. command itself.
  354.  
  355. FOR  can be nested. The depth of the nesting is limited only  by
  356. the  stack  space. If a new FOR command with  the  same  control
  357. variable  as that of an old FOR command is encountered, the  old
  358. FOR will be terminated automatically.
  359.  
  360.  
  361. STOP command
  362. ------------
  363.  
  364.         STOP
  365.  
  366. This  command  stops the execution of the program,  and  returns
  367. control to direct commands from the input device. It can  appear
  368. many  times  in a program, but must be the last command  in  any
  369. given statement; i.e., it cannot be followed by semicolon  (";")
  370. and other commands.
  371.  
  372.  
  373. DIRECT COMMANDS
  374. ---------------
  375.  
  376. As  defined earlier, a statement consists of a statement  number
  377. followed by commands. If the statement number is missing, or  if
  378. it is 0, the commands will be executed (instead of saved)  after
  379. you have typed the CR. All commands described above can be  used
  380. as  direct commands. There are three more commands that  can  be
  381. used as direct commands, but not as part of a statement:
  382.  
  383.         RUN
  384.  
  385. will  start  execution  of the program starting  at  the  lowest
  386. statement number.
  387.  
  388.         LIST
  389.  
  390. will print out all statements in ascending numerical order.
  391.  
  392.         LIST 120
  393.  
  394. will print out the statements starting at statement 120.
  395.  
  396.         LIST 120, 5
  397.  
  398. will print out 5 lines starting at statement 120.
  399.  
  400.         NEW
  401.  
  402. will delete all statements.
  403.  
  404.  
  405. STOPPING THE EXECUTION
  406. ----------------------
  407.  
  408. The execution of program, or listing of program, can be  stopped
  409. by typing Control-C.
  410.  
  411.  
  412. ABBREVIATION AND BLANKS
  413. -----------------------
  414.  
  415. You  may  use  blanks  freely,  except  that  numbers,   command
  416. keywords, and function names can not have embedded blanks.
  417.  
  418. You can truncate all command keywords and function names with  a
  419. period. 'P.', 'PR.', 'PRI.', and 'PRIN.' all stand for  'PRINT'.
  420. Also, the word LET in LET command can be omitted. The 'shortest'
  421. abbreviation for all keywords are as follows:
  422.  
  423.                 A. = ABS
  424.                 F. = FOR
  425.               GOS. = GOSUB
  426.                 G. = GOTO
  427.                 IF = IF
  428.                IN. = INPUT
  429.                  . = LIST
  430.                 N. = NEW
  431.                  . = NEXT
  432.                 P. = PRINT
  433.                REM = REMARK
  434.                 R. = RETURN
  435.                 R. = RND
  436.                 R. = RUN
  437.                 S. = SIZE
  438.                 S. = STEP
  439.                 S. = STOP
  440.                 TO = TO
  441.          (implied) = LET
  442.  
  443.  
  444. ERROR REPORT
  445. ------------
  446.  
  447. There  are  only  three  error conditions  in  Tiny  BASIC.  The
  448. statement that contains an error is printed out with a  question
  449. mark inserted at the point where the error is detected.
  450.  
  451. (1) WHAT? means it does not understand you.
  452.  
  453. Example:
  454.  
  455.         WHAT
  456.         210 P?TINT "THIS"
  457.  
  458. where PRINT is mistyped.
  459.  
  460.         WHAT?
  461.         260 LET A=(B+3?, C=3+4
  462.  
  463. where a close parenthesis is missing.
  464.  
  465.  
  466. (2) HOW? means it understands you, but does not know how to do it.
  467.  
  468.         HOW?
  469.         310 LET A=B*C?+2
  470.  
  471. where B*C is larger than 32767.
  472.  
  473.         HOW?
  474.         380 GOTO 412?
  475.  
  476. where statement 412 does not exist.
  477.  
  478.  
  479. (3)  SORRY means it understands you and knows how to do it,  but
  480. there is not enough memory to do it.
  481.  
  482.  
  483. ERROR CORRECTIONS
  484. -----------------
  485.  
  486. If you notice an error in typing before you hit the CR, you  can
  487. delete the last character by the BS (Control-H) key.
  488.  
  489. To correct a statement, you can retype the statement number with
  490. the correct commands. Tiny BASIC will replace the old  statement
  491. with the new one.
  492.  
  493. To  delete  a  statement, type  the  statement  number  followed
  494. immediately by a CR.
  495.  
  496.  
  497. EOF
  498.