home *** CD-ROM | disk | FTP | other *** search
/ ftp.whtech.com / ftp.whtech.com.tar / ftp.whtech.com / club100 / pg / pg200 / xbasic.do < prev   
Text File  |  2006-10-19  |  6KB  |  183 lines

  1. XBASIC.200 by Paul Globman [72227,1661]
  2.            copyright (c) 1988
  3.  
  4. XBASIC.CO is under 500 bytes and runs in the alternate LCD 
  5. buffer, so it will not overwrite DOS, or other .CO files 
  6. that are being used.  Once the BASIC program has executed 
  7. the LOADM"XBASIC" command, the all of the routines can be 
  8. accessed with the following call:
  9.  
  10.     CALL 63600,CMD [,VARPTR(X$)]
  11.  
  12. The commands are: 0 - CLOSE FILE
  13.                   1 - OPEN FOR INPUT
  14.                   2 - OPEN FOR APPEND
  15.                   3 - READ X$
  16.                   4 - WRITE X$
  17.                   5 - CHAIN FILE
  18.                   6 - DISPLAY FILES
  19.  
  20. XBASIC does internal error checking and will beep if there 
  21. is a problem.  XBASIC will not execute the wrong instruction
  22. and offers the BASIC programmer a result descriptor byte so 
  23. the BASIC program can trap and handle problems.
  24.  
  25. The result descriptor (RD) byte is at 63605, and can be 
  26. PEEKED either before or after a CALL to XBASIC.  There is 
  27. also an address pointer for the opened file at 63603 and 
  28. 63604, in the LSD/MSD format.
  29.  
  30.  
  31. THE COMMANDS
  32.  
  33.  
  34. CLOSE FILE.... CALL 63600,0
  35.  
  36. This command sets RD=0 and can be CALLED at anytime.  This 
  37. also sets the address pointer to 0.
  38.  
  39.  
  40. OPEN READ..... F$="2:FILE"
  41.                :CALL 63600,1,VARPTR(F$)
  42.  
  43. This command will first check the RD, and if RD=0 then it is
  44. OK to OPEN.  The OPEN READ command sets RD=1 and sets an 
  45. address pointer to the beginning of FILE.DO in bank #2.
  46.  
  47. If RD<>0 then it is NOT OK to OPEN (already open).  A BEEP 
  48. is sent and the open file is closed (RD set to 0).
  49.  
  50.  
  51. OPEN WRITE.... F$="2:FILE"
  52.                :CALL 63600,2,VARPTR(F$)
  53.  
  54. This command will first check the RD, and if RD=0 then it is
  55. OK to OPEN.  The OPEN WRITE command sets RD=2 and sets an 
  56. address pointer to the end of FILE.DO in bank #2.
  57.  
  58. If RD<>0 then it is NOT OK to OPEN (already open).  A BEEP 
  59. is sent and the open file is closed (RD set to 0).
  60.  
  61. READ.......... X$=""
  62.                :CALL 63600,3,VARPTR(X$)
  63.  
  64. This command will first check the RD, and if RD=1 then it is
  65. OK to READ.  The READ command leaves RD=1 unless an EOF CHR$
  66. (26) is found.  If an EOF is found then RD is set to 17.  
  67. When XBASIC returns from this CALL, X$ is set to the data 
  68. that was read.  The data read is from the address indicated 
  69. by the pointer to the next CR, to an EOF character, or 255 
  70. bytes.  Whichever comes first.  The address pointer is moved
  71. appropriately to the end of the data just read from FILE.DO 
  72. in bank #2.
  73.  
  74. If RD<>1 then it is NOT OK to READ.  Perhaps EOF was 
  75. encountered in the previous READ, or maybe the file was 
  76. opened for output.  A BEEP is sent and no read will take 
  77. place.  The RD is not altered so the user can inspect the 
  78. byte to see why a BEEP occurred.
  79.  
  80. WRITE......... X$="data"
  81.                :CALL 63600,4,VARPTR(X$)
  82.  
  83. This command will first check the RD, and if RD=2 then it is
  84. OK to WRITE.  The WRITE command leaves RD=2 unless an OM? 
  85. condition is found in the destination bank.  If an OM? is 
  86. found then RD is set to 18 and the WRITE does not occur.  
  87.  
  88. When XBASIC returns from this CALL, X$ is appended to the 
  89. data file that was opened for output.  X$ is written to the 
  90. address indicated by the pointer (end of file).  The address
  91. pointer is moved appropriately to the new end of the data 
  92. file in bank #2.  CR's are not automatically added.
  93.  
  94. If RD<>2 then it is NOT OK to WRITE.  Perhaps OM? was 
  95. encountered in the previous WRITE, or maybe the file was 
  96. opened for input.  A BEEP is sent and no write will take 
  97. place.  The RD is not altered so the user can inspect the 
  98. byte to see why a BEEP occurred.
  99.  
  100.  
  101. CHAIN......... BNK=2
  102.                :IPL"FILE.BA"
  103.                :CALL 63600,5,BNK
  104.  
  105. This command will jump to bank (BNK) and execute FILE.BA.  
  106. This is the only command that does NOT want the bank to be 
  107. part of the filename.  The file indicated by IPL must have a
  108. file extension.  You can CHAIN to a .DO file and that would 
  109. be like switching banks and jumping into TEXT to edit the 
  110. specified file.
  111.  
  112.  
  113. FILES......... BNK=2:CALL 63600,6,BNK
  114.  
  115. This command will display the files in bank (BNK) #2.
  116.  
  117. These commands should not always be used to address the 
  118. current bank where the  standard Basic commands (OPEN, 
  119. PRINT#, etc.) can be used.  These commands offer new 
  120. horizons for the T200 Basic programmer.
  121.  
  122. I've included a couple of sample programs to illustrate the 
  123. usability of XBASIC.
  124.  
  125. REATST.BA is an example of using XBASIC to read from another
  126. bank.  At the prompt enter the file you wish to duplicate.  
  127. That file will be copied to the current bank.
  128.  
  129. WRITST.BA is an example of using XBASIC to write to another 
  130. bank.  At the "Client" prompt, enter a name (use CAPS only).
  131.   WRITST will write the name to CLIENT.DO in either bank #1,
  132. #2, or #3.  WRITST.BA determines which bank to write to, 
  133. then opens the file for READING.  Names are read and when 
  134. the proper position is found for the current entry, the RD 
  135. byte is changed so a write operation can be performed.  This
  136. keeps CLIENT.DO in each bank sorted upon data insertion.
  137.  
  138. The apt Basic programmer could also develop RANDOM access to
  139. data files, as well as the sequential access we are now 
  140. accustomed to.  XBASIC.CO provides all the functions needed 
  141. to create some pretty sophisticated applications.
  142.  
  143.  
  144.  
  145. 0 REM REATST.BA
  146. 10 INPUT"x:file";F$
  147. 15 F$=LEFT$(F$+"      ",8)
  148. 20 F1$=RIGHT$(F$,6)
  149. 30 OPEN F1$ FOR OUTPUTAS1
  150. 40 LOADM"XBASIC":CALL63600,1,VARPTR(F$)
  151. 50 X$="":CALL63600,3,VARPTR(X$)
  152. 60 PRINT#1,X$;
  153. 70 IF PEEK(63605)=17 THEN MENU
  154. 75 PRINT".";
  155. 80 IF LEN(X$)<>255THENPRINT#1,""
  156. 90 GOTO50
  157.  
  158.  
  159.  
  160.  
  161.  
  162. 10 'WRITST.BA by Paul Globman
  163. 20 ' get input data and determine bank
  164. 30 CLS:PRINT:INPUT"Client";CL$
  165. 40 IF(ASC(CL$)AND223)=ASC(CL$)THEN60
  166. 50 BEEP:PRINT"use CAPS only please"
  167. 55 FORI=1TO399:NEXT:RUN
  168. 60 IF CL$<"I"THENBNK=1:GOTO90
  169. 70 IF CL$=>"Q"THEN BNK=3:GOTO90
  170. 80 BNK=2
  171. 90 CL1$=CL$+CHR$(13)+CHR$(10)
  172. 100 ' open file and locate position
  173. 110 F$=CHR$(BNK+48)+":CLIENT"
  174. 120 LOADM"XBASIC":CALL63600,1,VARPTR(F$)
  175. 130 P1=PEEK(63603):P2=PEEK(63604)
  176. 140 X$="":CALL63600,3,VARPTR(X$)
  177. 150 IF PEEK(63605)=17 THEN 180
  178. 160 IF X$<CL$ THEN 130
  179. 170 ' write data into place
  180. 180 POKE63603,P1:POKE63604,P2:POKE63605,2
  181. 190 CALL 63600,4,VARPTR(CL1$)
  182. 200 RUN
  183.