home *** CD-ROM | disk | FTP | other *** search
/ ftp.whtech.com / ftp.whtech.com.tar / ftp.whtech.com / club100 / pg / pgxos / xbasic.200 < prev    next >
Text File  |  2006-10-19  |  9KB  |  256 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. 1 '************************
  145. 2 '*  XBASIC.CO           *
  146. 3 '*    by Paul Globman   *
  147. 4 '*  Copyright (c) 1988  *
  148. 5 '************************
  149. 10 FOR I = 63572 TO 64043 
  150. 20 READ X:POKE I,X:SM=SM+X
  151. 30 NEXT
  152. 40 IF SM = 65761 THEN 60
  153. 50 PRINT"error in data":STOP
  154. 60 SAVEM"XBASIC.CO",63572,64043
  155. 1000 DATA 197,6,0,213,86,227,205,176
  156. 1010 DATA 155,209,235,193,35,19,11,121
  157. 1020 DATA 176,194,84,248,201,243,205,177
  158. 1030 DATA 155,251,122,201,195,118,248,0
  159. 1040 DATA 0,0,167,202,184,248,254,6
  160. 1050 DATA 202,230,249,254,5,202,172,249
  161. 1060 DATA 254,4,202,194,248,254,3,202
  162. 1070 DATA 98,249,71,58,117,248,167,194
  163. 1080 DATA 181,248,120,50,17,249,50,117
  164. 1090 DATA 248,205,198,249,35,35,95,205
  165. 1100 DATA 202,90,33,70,247,17,70,247
  166. 1110 DATA 1,6,0,205,84,248,195,229
  167. 1120 DATA 248,205,69,79,33,0,0,34
  168. 1130 DATA 115,248,34,116,248,201,50,17
  169. 1140 DATA 249,58,117,248,254,2,194,69
  170. 1150 DATA 79,229,126,254,0,111,38,0
  171. 1160 DATA 34,48,249,225,200,35,235,237
  172. 1170 DATA 34,75,249,42,115,248,34,45
  173. 1180 DATA 249,243,219,216,230,12,50,54
  174. 1190 DATA 249,56,0,235,34,58,249,33
  175. 1200 DATA 254,248,84,93,1,59,0,205
  176. 1210 DATA 84,248,62,0,211,216,71,58
  177. 1220 DATA 54,249,184,202,16,249,49,156
  178. 1230 DATA 249,205,71,76,62,0,254,4
  179. 1240 DATA 202,44,249,254,2,33,76,247
  180. 1250 DATA 54,68,35,54,79,245,205,124
  181. 1260 DATA 45,241,204,104,130,195,53,249
  182. 1270 DATA 33,0,0,1,255,255,205,168
  183. 1280 DATA 130,62,0,211,216,49,0,0
  184. 1290 DATA 245,58,17,249,254,4,194,82
  185. 1300 DATA 249,241,218,88,249,235,33,0
  186. 1310 DATA 0,205,84,248,235,245,241,34
  187. 1320 DATA 115,248,251,201,205,69,79,62
  188. 1330 DATA 18,50,117,248,251,201,58,117
  189. 1340 DATA 248,254,1,194,69,79,243,229
  190. 1350 DATA 58,255,248,71,14,1,17,112
  191. 1360 DATA 239,42,115,248,43,35,213,197
  192. 1370 DATA 205,177,155,122,193,209,254,26
  193. 1380 DATA 202,164,249,254,13,202,147,249
  194. 1390 DATA 18,19,12,194,121,249,43,35
  195. 1400 DATA 35,34,115,248,121,61,225,119
  196. 1410 DATA 35,235,33,112,239,217,251,201
  197. 1420 DATA 62,17,50,117,248,195,149,249
  198. 1430 DATA 243,125,205,213,249,33,221,244
  199. 1440 DATA 229,209,1,11,0,205,84,248
  200. 1450 DATA 205,26,28,58,86,248,79,195
  201. 1460 DATA 144,155,126,61,61,35,235,237
  202. 1470 DATA 245,126,214,48,205,213,249,241
  203. 1480 DATA 201,71,62,1,135,5,194,216
  204. 1490 DATA 249,230,12,50,255,248,50,86
  205. 1500 DATA 248,201,125,205,213,249,71,33
  206. 1510 DATA 181,242,205,105,248,254,255,200
  207. 1520 DATA 254,240,202,254,249,230,128,194
  208. 1530 DATA 5,250,17,11,0,25,195,238
  209. 1540 DATA 249,205,30,0,35,35,35,205
  210. 1550 DATA 105,248,231,62,8,61,202,35
  211. 1560 DATA 250,50,16,250,254,2,194,10
  212. 1570 DATA 250,62,46,231,195,10,250,62
  213. 1580 DATA 8,50,16,250,35,195,238,249 
  214. 1590 REM    END OF DATA
  215.  
  216.  
  217.  
  218. 0 REM REATST.BA
  219. 10 INPUT"x:file";F$
  220. 15 F$=LEFT$(F$+"      ",8)
  221. 20 F1$=RIGHT$(F$,6)
  222. 30 OPEN F1$ FOR OUTPUTAS1
  223. 40 LOADM"XBASIC":CALL63600,1,VARPTR(F$)
  224. 50 X$="":CALL63600,3,VARPTR(X$)
  225. 60 PRINT#1,X$;
  226. 70 IF PEEK(63605)=17 THEN MENU
  227. 75 PRINT".";
  228. 80 IF LEN(X$)<>255THENPRINT#1,""
  229. 90 GOTO50
  230.  
  231.  
  232.  
  233.  
  234.  
  235. 10 'WRITST.BA by Paul Globman
  236. 20 ' get input data and determine bank
  237. 30 CLS:PRINT:INPUT"Client";CL$
  238. 40 IF(ASC(CL$)AND223)=ASC(CL$)THEN60
  239. 50 BEEP:PRINT"use CAPS only please"
  240. 55 FORI=1TO399:NEXT:RUN
  241. 60 IF CL$<"I"THENBNK=1:GOTO90
  242. 70 IF CL$=>"Q"THEN BNK=3:GOTO90
  243. 80 BNK=2
  244. 90 CL1$=CL$+CHR$(13)+CHR$(10)
  245. 100 ' open file and locate position
  246. 110 F$=CHR$(BNK+48)+":CLIENT"
  247. 120 LOADM"XBASIC":CALL63600,1,VARPTR(F$)
  248. 130 P1=PEEK(63603):P2=PEEK(63604)
  249. 140 X$="":CALL63600,3,VARPTR(X$)
  250. 150 IF PEEK(63605)=17 THEN 180
  251. 160 IF X$<CL$ THEN 130
  252. 170 ' write data into place
  253. 180 POKE63603,P1:POKE63604,P2:POKE63605,2
  254. 190 CALL 63600,4,VARPTR(CL1$)
  255. 200 RUN
  256.