Path: utzoo!attcan!uunet!lll-winken!ames!mailrus!csd4.milw.wisc.edu!uwmcsd1!marque!studsys!jetzer From: jetzer@studsys.mu.edu (jetzer) Newsgroups: comp.sys.apple Subject: Re: Getting a CATALOG into a file Keywords: CATALOG Message-ID: <363@studsys.mu.edu> Date: 26 Jan 89 04:48:39 GMT References: <410f8301.14dd6@c> Organization: Marquette University - Milwaukee, Wisconsin Lines: 69 In article <410f8301.14dd6@c>, bauer@procase.UUCP (Jerry Bauer) writes: > Alright, class, today's question is: > > Under ProDOS, in APPLESOFT, how can one get a list of the files on > a given disk (CATALOG) into a file? > > > This code DOESN'T work: > > 100 PRINT CHR$(4);"OPEN TEMP.CATALOG" > 110 PRINT CHR$(4);"WRITE TEMP.CATALOG" > 120 CATALOG > 130 PRINT CHR$(4);"CLOSE TEMP.CATALOG" > > because line 120 becomes: > > 120 C AT A LOG > > (Isn't APPLESOFT wonderful?) APPLESOFT is wonderful, but this one is not APPLESOFT's fault. The logical thing to do would have been to issue the ProDOS command, CATALOG (which is a ProDOS, not APPLESOFT command). Line 120 would read 120 PRINT CHR$(4)"CATALOG". Of course, I did say "the logical thing to do." You should know better than to do what seems logical ( :-) ). Any (or just about any) time you print a CTRL-D while a file is open, the file is closed. This means that the logical, and easiest, approach won't work. You'd need to (watch someone prove me wrong ...) write a program similar to the following: 10 DIM N$(56) :REM room for 51 files, plus 5 extra lines (I think it's five) 20 D$ = CHR$(4) 30 ? D$"OPEN /VOLUME,TDIR" 40 ? D$"READ /VOLUME" 50 X = 1 60 INPUT N$(X): IF LEFT$(N$,1) <> "B" THEN X = X + 1: GOTO 60 70 REM The check is made in 60 to see if you have read the last line of 80 REM the catalog, which begins "BLOCKS ...", which begins with "B" 90 ? D$"CLOSE /VOLUME" 100 ?D$"OPEN TEMP.CATALOG" 110 ?D$"WRITE TEMP.CATALOG" 120 FOR Y = 1 TO X 130 ? N$(Y) 140 NEXT Y 150 ? D$"CLOSE TEMP.CATALOG" Of course, this is just off the top of my head, so your mileage may vary. The /VOLUME would, of course, be replaced with the directory which you wish to catalog. If you are doing a subdirectory, you may want to increase the boundary of the DIM in line 10 (root directories are limited to 51 files, but there is no [meaningful] limit on the number of files in a subdirectory). A completely different way to do this is to obtain a program from apple2-l. I believe the program's name is COMO, which adds a command to ProDOS which will send all output from the screen into a file. I don't recall if it's PD or shareware. I haven't used it, so I don't know if/how well it works. Disclaimer: Hey, it's almost midnight, and I qualified [almost] everything that was specific and I wasn't real sure about ... -- Mike Jetzer "Hack first, ask questions later."