One of my favorite chores used to be clearing files off my diskettes, making room for new programs and files. Of course I'm kidding; I dreaded purging diskettes. First you had to load DOS and wait. Filenames had to be carefully entered, and finally the DELETE D:SLOW ? Y or N had to be dealt with. You also had to add one more step if the file was locked, or do it over from the start if you made a mistake. Repeat the above steps for each file you want deleted, and the entire process can easily take 20 minutes per diskette. "Purge" was written to make this job fast and easy, freeing your valuable time for other things.
When Purge is finished clearing your diskette, a directory is printed on the screen. The directory has two advantages over the DOS directory. First, you do not need to load DOS to use it. Second, the files are printed in two columns, allowing twice as many files to be displayed before they start scrolling off the top of the screen.
The program is written in two short sections, which makes it easy to save the DIR (Section A) as a separate program. The REMarks at the end of section A will explain this in more detail. I keep a copy of DIR on each of my diskettes. It requires only three sectors of disk space, well worth the time it can save you. I also have a LISTed version of DIR on a file named EDIR. I simply ENTER "D:EDIR" with any program I happen to have in memory. The high line numbers will almost never cause a conflict. Just type GOTO 32100 for a directory listing. DIR will now be a part of the program.
To use Purge, simply load the program, insert the diskette to be purged into disk drive one, and type RUN. One at a time the files on that diskette will be displayed on the screen. Pressing RETURN will display the next file. When an unwanted file is displayed, press CONTROL <P> to purge it. This process continues until all the files have been displayed. Don't panic if you make an error along the way; just press BREAK and start over. The purging takes place after all the files have been displayed and only if you press P, as prompted on the screen. You'll hear a lot of action from the disk drive as the purging is taking place. The length of this operation varies with the number and length of files being deleted.
The following is a line by line description of my program. This will be of most interest to programmers with limited experience working with disk operations. The XIO feature is the key to Purge. Writing this program in BASIC would have been very difficult without XIO. Note that the program listing does not have all the lines in correct order.
Line 32100 | This special OPEN will allow inputs from the disk directory. The "*.*" in the filename is the same as a wildcard in DOS. | |
Line 32102 | The TRAP is very useful. In this case it will detect the EOF (end of file), treat it as an error, and end the inputs. | |
Line 32104-32106 | These are the INPUT(s) from the directory. The directory is printed in two columns. | |
Line 32110-32115 | The file is CLOSEd, and the program goes into an endless loop to prevent possible information from scrolling off the screen. | |
Line 32000 | Another TRAP for EOF. The keyboard (K:) is OPENed for input. | |
Line 32004 | The OPEN is again to the directory. | |
Line 32006 | One at a time each directory entry is INPUT and tested for FREE SECTORS, which would be the last entry. The entry is then printed on the screen. | |
Line 32008 | The program waits for an input from the keyboard. A chime sounds and slows things a bit. | |
Line 32010 | If a purge was requested, the filename is created from the directory information. | |
Line 32012 | The filename is saved in a larger string for later purging. | |
Line 32016-32017 | Blank spaces have to be removed from the filename before they can be unlocked and deleted. | |
Line 32018 | The XIO's perform unlock and delete just as if you were using DOS. | |
Line 32020 | Files are CLOSEd, and the DIR routine will follow. |
32050 REM SECTION (A) DIR 32055 REM 32060 REM WHEN FINISHED TYPING THIS SECTION SAVE IT WITH THE FILE NAME 'D:DIR'. 32065 REM ALSO LIST IT TO THE DISKETTE WITH THE FILE NAME{3 SPACES}'D:EDIR'. 32067 REM 'EDIR' CAN THEN BE ENTERED AT ANY TIME TO ATTACH A 'DIR' 32068 REM TO YOUR PROGRAM TO BE CALLED WITH A 'GOTO 32100'. 32070 REM THEN CONTINUE ADDING SECTION (B) TO SECTION (A) 32100 OPEN #5,6,0,"D:*.*" 32102 CLR :GRAPHICS 0:POKE 82,1:DIM ENT$(17):TRAP 32110:? :? " DISK DIRECTORY{21 SPACES}" 32104 INPUT #5,ENT$:? ENT$;"{4 SPACES}"; 32106 INPUT #5,ENT$:? ENT$:GOTO 32104 32110 CLOSE #5:? :? "{4 SPACES}END{8 SPACES}PRESS BREAK{5 SPACES}END{3 SPACES}";:POKE 82,2 32115 GOTO 32115
Listing. Section A: DIR.
Download (Saved BASIC) / Download (Listed BASIC)
31900 REM SECTION (B) PURGE 31910 REM 32000 TRAP 32013:OPEN #4,4,0,"K:":DIM E$(17),S$(500),PG$(14):X=1:Y=14 32002 GRAPHICS 0:? "{DOWN}TO PURGE":? "{DOWN}AFTER EACH FILE DISPLAYED PRESS":? "CONTROL-P TO DELETE OR{3 SPACES}PRESS RETURN" 32004 ? "TO CONTINUE":OPEN #5,6,0,"D:*.*" 32006 INPUT #5,E$:POSITION 2,10:IF E$(5,16)<>"FREE SECTORS" THEN ? E$:? :? " CHOICE";:GOTO 32008 32007 GOTO 32013 32008 GET #4,K:IF K<>16 THEN POSITION 2,12:? " CHOICE ":FOR Q=15 TO 0 STEP -0.2:SOUND 0,20,10,Q:NEXT Q:GOTO 32006 32010 PG$(1,2)="D:":PG$(3,10)=E$(3,10):PG$(11,11)=".":PG$(12,14)=E$(11,13) 32012 S$(X,Y)=PG$:X=X+14:Y=Y+14:FOR Q=15 TO 0 STEP -0.2:SOUND 0,40,10,Q:NEXT Q:GOTO 32006 32013 POSITION 2,15:? "PRESS P TO PURGE";:FOR Q=1 TO 120:POKE 764,255:NEXT Q:GET #4,K:IF K=80 THEN 32015 32014 GOTO 32020 32015 X=1:Y=14:S=0 32016 TRAP 32020:PG$=S$(X,Y):FOR Q=1 TO 13:S=S+1:IF PG$(S,S)=" " THEN PG$(S,14)=PG$(S+1,14):S=S-1 32017 NEXT Q 32018 XIO 36,#3,0,0,PG$:XIO 33,#3,0,0,PG$:X=X+14:Y=Y+14:S=0:GOTO 32016 32020 CLOSE #4:CLOSE #5
Listing. Section B: Purge.
Download (Saved BASIC) / Download (Listed BASIC)
Listing. Purge and DIR Complete Listing.
Download (Saved BASIC) / Download (Listed BASIC)
Return to Table of Contents | Previous Section | Next Section