As you begin to amass files and programs on the QL’s little matchbook-sized cartridges, you will run into the problem of generating backups of your files. Our trusty manual tells us to “simply” type “COPY mdv1_file_name TO mdv2_file_n_bak” or some such. Not impossible, but if you’re trying to copy more than one file it can add up to an awful lot of typing.
CLONE represents another way of generating backups – but it requires a DATA statement containing the names of the files to be copied: another quantity of typing.
CLEANUP/BACKUP offers a third alternative. Like CLONE, it allows the user to duplicate an entire source cartridge (on mdv2_), but, in addition it allows you to select the files to be copied. In this way, you can both eliminate those earlier versions of the program you’ve been working on, and re-arrange the order of programs in the cartridge for easier reference.
For instance, you could re-arrange your files in alphabetical order (with BOOT first, of course); or sort your ARCHIVE data files so as to group all the screen files, then all the program files, then all the data files in sequence for a given application.
To use the program, LOAD it, place the desired source cartridge in mdv2_, and RUN. You will be prompted to make sure there is a destination cart. in mdv1_. Upon confirming that, you will be shown a list of the contents of both drives, as well as a menu of your options. They are generally self-explanatory, but I should stress that the (D)elete option deletes the file from mdv2_, not mdv1_.
The Works:
CLEANUP/BACKUP is divided into three parts. Parts one and two are fully automatic. Part one (lines 100 – 270) temporarily sets up a data file on mdv2_ to hold the directory as it is read from the header. Part two (lines 280 – 340) then transfers this file to an array, and deletes the microdrive file. Part three, “select_fil,” presents you with the contents of mdv1_ and mdv2_, and allows you to choose your next course of action. Line 1020 allows you to easily update the copy of the program on your microdrive, if you improve the program.
As it is set up now, it will handle cartridges with up to 14 files. The limitation stems from the size of the display. It would be possible to use the WINDOW and SCROLLing facilities of SUPERbasic to remove this limitation, but I’m not up to that yet. Anyone that is interested in the project should feel free to write it up.
100 REMark ***** cleanup/ backup utility *****
110 WINDOW 500,235,0,0: INK 7: PAPER 0
120 REMark Create file to hold DIR
130 OPEN_NEW#4,mdv2_direc
140 DIR #4, mdv2_
150 PRINT #4, CHR$(26)
160 CLOSE #4
170 PRINT 'Loading Array with file names'
180 OPEN_IN #4,mdv2_direc : CLS
190 LET count=0
200 REPeat rd
210 count=count+1
220 INPUT #4, a$
230 IF EOF (#4): EXIT rd
240 END REPeat rd
250 count=count-3
260 PAUSE 200
270 CLOSE #4
280 DIM dir$(count,30)
290 OPEN_IN #4,mdv2_direc : CLS
300 FOR i=0 TO count
310 INPUT #4, dir$(i)
320 END FOR i
330 CLOSE #4
340 DELETE mdv2_direc
350 select_fil
360 STOP
370 DEFine PROCedure prdir
380 FOR i=0 TO count
390 PRINT TO 40;dir$(i)
400 END FOR i
410 END DEFine
420 DEFine PROCedure select_fil
430 CLS
440 PRINT 'Cartridge in MDV1_? Press space to continue - (Q)
to Quit ': r$=INKEY$(-1)
450 CLS : IF r$()' ' THEN EXIT select_fil
460 PRINT 'MDV1 now contains:'; TO 40;'MDV2 now contains:'\\
470 prdir : num=2 : AT 2,0: DIR mdv1_
480 AT 20,0
490 PRINT 'Press : (C)opy all files -- MDV1 WILL BE ERASED [illegible]
ENTER) to copy selected file'
500 PRINT ' (D)elete selected program [illegible]
F)ormat MDV1'
510 PRINT ' (^ or v) Select files [illegible]
Q)uit'
550 REPeat updn
560 AT num+2,35: PRINT'---)'
570 key = CODE (INKEY$(-1))
580 AT num+2,35: PRINT' '
590 num=num+(key=216)-(key=208)
600 IF num)count THEN num=count
610 IF num(2 THEN num=2
620 IF key=10 THEN cpy:AT 2,0: DIR mdv1_
630 IF key=CODE('c') THEN cpyall
640 IF key=CODE('d') THEN del
650 IF key=CODE('f') THEN fmt
660 IF key=CODE('q') OR key=CODE('Q') THEN EXIT updn
670 END REPeat updn
680 END DEFine
690 DEFine PROCedure fmt
700 a$=dir$(0, 1 TO ' ' INSTR(dir$(0))-1) : PAUSE 50 : a$=a$(
1 TO 6)&'_bak'
710 AT 19,0: PRINT 'Press ENTER to format as'!a$!', Q to quit
, or type new vol. name:'; : INPUT !q$;
720 CLS 3
730 IF q$='q' OR q$='Q' THEN RETurn
740 IF q$()'' THEN a$=q$
750 AT 19,0: FORMAT "mdv1_"&a$ ;: CLS 3
760 AT 2,0: DIR mdv1_: PRINT ' '
770 END DEFine
780 DEFine PROCedure cpy
790 a$=dir$(num)
800 IF a$='000000' THEN RETurn
810 COPY "mdv2_"&a$ TO "mdv1_"&a$
820 END DEFine
830 DEFine PROCedure cpyall
840 fmt
850 FOR num=2 TO count
860 cpy
870 END FOR num
880 AT 2,0
890 DIR mdv1_
900 PRINT ' '
910 END DEFine
920 DEFine PROCedure del
930 a$=dir$(num)
940 IF a$='000000' THEN RETurn
950 AT 19,0: PRINT 'DELETING ';a$;'. Press SPACE to continue,
(Q) to abort:';:q$=INKEY$(-1)
960 CLS 3: IF q$='q'THEN RETurn
970 AT num+2,40: OVER 1 : PRINT '--------------------------':
OVER 0
980 DELETE 'mdv2_'&a$
990 dir$(num)='000000'
1000 END DEFine
1010 STOP
1020 DELETE mdv2_cleanup: SAVE mdv2_cleanup
Reprinted from the Feb/87 issue of CATS: the Capital Area TS Users Group newsletter
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.