Over a year ago, I read a request asking how to use the FOP_OVER facility found in TK2_EXTensions instead of OPEN_NEW.
Others are better qualified to explain some of this. Let me simply state that you need to OPEN a device before you can access it; and, when you are done using it, you should CLOSE it.
Using FOP_OVER lets you set an error trap for a “bad” medium — where “bad” can mean any of a variety of problems such as a missing physical medium. If the error is recognized, instead of having the program crash, recovery can be to another location in the program.
The following examples are actual PROCedures used in both QLAMBer (FOP_OVER) and QLATter (OPEN_NEW). I hope this is still useful information, and my apologies for its tardiness.
HERE’S HOW
Comparing and contrasting should be the easiest way to see how comparable tasks are implemented; so, this is more show then tell.
To begin with the obvious, here is the PROCedure used in QLATter.
650 DEFine PROCedure Access: DIM Z$(610,32): DELETE t$&a&F$
660 OPEN_NEW#6,t$&a&F$
670 DIR#6,t$a&"_"&RN$: CLOSE#6
680 OPEN_IN#7,t$&a&F$: FOR c=0 TO 610
690 IF EOF(#7) THEN EXIT c
700 INPUT#7,Z$(c): END FOR c: CLOSE#7: c=c-1: END IF : END DEFine
You should be able to see that the PROCedure using FOP_OVER is very similar.
650 DEFine PROCedure Access: DIM Z$(610,32): DELETE t$&a&F$
660 uk=FOP_OVER(#6,t$&a&F$):
IF uk<0 THEN iX: CLSd: AT#2,24,37: REPORT#2,uk:
PAUSE 50: zCLS: tre=0: WCh
670 DIR#6,t$&a&"_"&RN$: CLOSE#6
680 OPEN_IN#7,t$&a&F$: FOR c=0 TO 610
690 IF EOF(#7) THEN EXIT c
700 INPUT#7,Z$(c): END FOR c: CLOSE#7: c=c-1: END IF :
END DEFine
Z$(q,l) is a DIMensioned array where ‘q’ is the number of entries (in this case 610, two of which are related to the medium header) and ‘l’ (the filename length is 32 characters long in this instance).
I use variables, but you don’t have to:
t$ = "flp"
a = 1
F$ = "_FLIST_imp"
RN$ = (this is optional; and, can be omitted)
nnn DEFine PROCedure ix: PRINT "invalid device":END DEFine
nnn DEFine PROCedure zCLS: (clears part of the screen)
nnn DEFine PROCedure WCh: (this is where I want the program re-directed; 'tre' is a pointer).
I hope these two examples and limited explanation are adequate.
If you have any questions, feel free to contact me.
Happy Trails,
And Computing, To You ….