Classic Computer Magazine Archive COMPUTE! ISSUE 30 / NOVEMBER 1982 / PAGE 183

Purge

Al Casper Saukville, WI

For the Atari 800 with 810 disk drive, this is a quicker and simpler method of housecleaning diskettes.

It's summertime; free time for my Atari 800 is now carefully rationed. 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; 1 dreaded purging diskettes. First you had to load DOS and wait. File names 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 twenty minutes per diskette. Purge was written to make this job fast and easy, freeing your valuable time for other things.

Free Directory

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 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.

XIO Examples

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 file name 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 file name is created from the directory information.
Line 32012 The file name is saved in a larger string for later purging.
Line 32016-32017 Blank spaces have to be removed from the file name before they can be unlocked and deleted.
Line 32018 The XIO's perform unlock and delete just as if you were using DOS.
Line 32030 Files are CLOSEd, and the "DIR" routine will follow.

Program 1: Section A: DIR

32050 REH SECTION (A) DIR
32055 REM
32060 REM WHEN FINISHED TYPINB THIS SECTION SAVE IT WITH THE FILE NAME 'D : DIR'.
32065 REM ALSO LIST IT TO THE DISKETTE WITH THE FILE NAME 'D;EDIR'
32067 REM 'EDIR' CAN THEN BE ENTERED AT ANY TIME TO ATTACH A 'DIR"
32068 REM TO YOUR PROBRAM TO BE CALLED WITH A 'BOTO 32100'.
32070 REM THEN CONTINUE ADDING SECTION (B) TO SECTION (A)
32100 OPEN #5,6,O,"D : *.*"
32102 CLR : BRAPHICS 0;P0KE 82,1 : DIM ENT$ (17) : TRAP 32110 : ? : ?""
32104 INPUT #5,ENT$ : ? ENT$ : " ";
32106 INPUT #5,ENT$ : ? ENT$ : GOTO 321O4
32110 CLOSE #5 : ? : ? "
"; :  POKE 82,2
32115 GOTO 32115

Program 2: Section B: Purge

31900 REM SECTION (B) PURGE
31910 REM
32000 TRAP 32013 : 0PEN #4,4,O, "K : " : D I M E$(17) ,S$ (500) ,PG$ ( 14) :  X = l : Y = 14
32002 GRAPHICS O : ? "{DOWN} TO PURBE" : ? "{DOWN}AFTER
      EACH FILE DISPLAYED PRESS" : ? "CONTROL-P TO DELETE
      OR PRESS RETURN"
32004 ? "TO CONTINUE" : OPEN #5,6,0,"D :
*. *"
32006 INPUT #5,E$ : POSITION 2,1O : IF E$ (5,16)<>"FREE SECTORS" THEN ? E$ : ?  : ? ";  :  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,1O,Q : NEXT Q : GOT0 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 O STEP -O.2 : SOUND 0,40,1 O,Q : NEXT Q : GOTO 32006
32013 POSITION 2,15 : ? "";
       : FOR Q = l TO 120 : P0KE 764,25 5 : NEXT Q
       : GET #4,K : IF K = 80 THEN 32015
32014 GOTO 32020
32015 X = l : Y = 14 : S = 0
32016 TRAP 32O2O : PB$ = S$(X,Y) : FOR Q = 1 TO 13
       : S-S+l : IF PG$(S,S) = " " THE N PB$
       (S,14) = P6$(S+l,14) : S = S-1
32017 NEXT Q
32018 XIO 36,#3,O,O,PS$ : XIO 33,#3,0,0,PG$ : X = X+14 : Y =
      Y+14 : S = O : GOTO 32016
3202O CLOSE #4 : CL0SE #5