home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.whtech.com
/
ftp.whtech.com.tar
/
ftp.whtech.com
/
club100
/
pg
/
pg200
/
xbasic.do
< prev
Wrap
Text File
|
2006-10-19
|
6KB
|
183 lines
XBASIC.200 by Paul Globman [72227,1661]
copyright (c) 1988
XBASIC.CO is under 500 bytes and runs in the alternate LCD
buffer, so it will not overwrite DOS, or other .CO files
that are being used. Once the BASIC program has executed
the LOADM"XBASIC" command, the all of the routines can be
accessed with the following call:
CALL 63600,CMD [,VARPTR(X$)]
The commands are: 0 - CLOSE FILE
1 - OPEN FOR INPUT
2 - OPEN FOR APPEND
3 - READ X$
4 - WRITE X$
5 - CHAIN FILE
6 - DISPLAY FILES
XBASIC does internal error checking and will beep if there
is a problem. XBASIC will not execute the wrong instruction
and offers the BASIC programmer a result descriptor byte so
the BASIC program can trap and handle problems.
The result descriptor (RD) byte is at 63605, and can be
PEEKED either before or after a CALL to XBASIC. There is
also an address pointer for the opened file at 63603 and
63604, in the LSD/MSD format.
THE COMMANDS
CLOSE FILE.... CALL 63600,0
This command sets RD=0 and can be CALLED at anytime. This
also sets the address pointer to 0.
OPEN READ..... F$="2:FILE"
:CALL 63600,1,VARPTR(F$)
This command will first check the RD, and if RD=0 then it is
OK to OPEN. The OPEN READ command sets RD=1 and sets an
address pointer to the beginning of FILE.DO in bank #2.
If RD<>0 then it is NOT OK to OPEN (already open). A BEEP
is sent and the open file is closed (RD set to 0).
OPEN WRITE.... F$="2:FILE"
:CALL 63600,2,VARPTR(F$)
This command will first check the RD, and if RD=0 then it is
OK to OPEN. The OPEN WRITE command sets RD=2 and sets an
address pointer to the end of FILE.DO in bank #2.
If RD<>0 then it is NOT OK to OPEN (already open). A BEEP
is sent and the open file is closed (RD set to 0).
READ.......... X$=""
:CALL 63600,3,VARPTR(X$)
This command will first check the RD, and if RD=1 then it is
OK to READ. The READ command leaves RD=1 unless an EOF CHR$
(26) is found. If an EOF is found then RD is set to 17.
When XBASIC returns from this CALL, X$ is set to the data
that was read. The data read is from the address indicated
by the pointer to the next CR, to an EOF character, or 255
bytes. Whichever comes first. The address pointer is moved
appropriately to the end of the data just read from FILE.DO
in bank #2.
If RD<>1 then it is NOT OK to READ. Perhaps EOF was
encountered in the previous READ, or maybe the file was
opened for output. A BEEP is sent and no read will take
place. The RD is not altered so the user can inspect the
byte to see why a BEEP occurred.
WRITE......... X$="data"
:CALL 63600,4,VARPTR(X$)
This command will first check the RD, and if RD=2 then it is
OK to WRITE. The WRITE command leaves RD=2 unless an OM?
condition is found in the destination bank. If an OM? is
found then RD is set to 18 and the WRITE does not occur.
When XBASIC returns from this CALL, X$ is appended to the
data file that was opened for output. X$ is written to the
address indicated by the pointer (end of file). The address
pointer is moved appropriately to the new end of the data
file in bank #2. CR's are not automatically added.
If RD<>2 then it is NOT OK to WRITE. Perhaps OM? was
encountered in the previous WRITE, or maybe the file was
opened for input. A BEEP is sent and no write will take
place. The RD is not altered so the user can inspect the
byte to see why a BEEP occurred.
CHAIN......... BNK=2
:IPL"FILE.BA"
:CALL 63600,5,BNK
This command will jump to bank (BNK) and execute FILE.BA.
This is the only command that does NOT want the bank to be
part of the filename. The file indicated by IPL must have a
file extension. You can CHAIN to a .DO file and that would
be like switching banks and jumping into TEXT to edit the
specified file.
FILES......... BNK=2:CALL 63600,6,BNK
This command will display the files in bank (BNK) #2.
These commands should not always be used to address the
current bank where the standard Basic commands (OPEN,
PRINT#, etc.) can be used. These commands offer new
horizons for the T200 Basic programmer.
I've included a couple of sample programs to illustrate the
usability of XBASIC.
REATST.BA is an example of using XBASIC to read from another
bank. At the prompt enter the file you wish to duplicate.
That file will be copied to the current bank.
WRITST.BA is an example of using XBASIC to write to another
bank. At the "Client" prompt, enter a name (use CAPS only).
WRITST will write the name to CLIENT.DO in either bank #1,
#2, or #3. WRITST.BA determines which bank to write to,
then opens the file for READING. Names are read and when
the proper position is found for the current entry, the RD
byte is changed so a write operation can be performed. This
keeps CLIENT.DO in each bank sorted upon data insertion.
The apt Basic programmer could also develop RANDOM access to
data files, as well as the sequential access we are now
accustomed to. XBASIC.CO provides all the functions needed
to create some pretty sophisticated applications.
0 REM REATST.BA
10 INPUT"x:file";F$
15 F$=LEFT$(F$+" ",8)
20 F1$=RIGHT$(F$,6)
30 OPEN F1$ FOR OUTPUTAS1
40 LOADM"XBASIC":CALL63600,1,VARPTR(F$)
50 X$="":CALL63600,3,VARPTR(X$)
60 PRINT#1,X$;
70 IF PEEK(63605)=17 THEN MENU
75 PRINT".";
80 IF LEN(X$)<>255THENPRINT#1,""
90 GOTO50
10 'WRITST.BA by Paul Globman
20 ' get input data and determine bank
30 CLS:PRINT:INPUT"Client";CL$
40 IF(ASC(CL$)AND223)=ASC(CL$)THEN60
50 BEEP:PRINT"use CAPS only please"
55 FORI=1TO399:NEXT:RUN
60 IF CL$<"I"THENBNK=1:GOTO90
70 IF CL$=>"Q"THEN BNK=3:GOTO90
80 BNK=2
90 CL1$=CL$+CHR$(13)+CHR$(10)
100 ' open file and locate position
110 F$=CHR$(BNK+48)+":CLIENT"
120 LOADM"XBASIC":CALL63600,1,VARPTR(F$)
130 P1=PEEK(63603):P2=PEEK(63604)
140 X$="":CALL63600,3,VARPTR(X$)
150 IF PEEK(63605)=17 THEN 180
160 IF X$<CL$ THEN 130
170 ' write data into place
180 POKE63603,P1:POKE63604,P2:POKE63605,2
190 CALL 63600,4,VARPTR(CL1$)
200 RUN