Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ncar!ames!pasteur!ucbvax!UIAMVS.BITNET!AWCTTYPA From: AWCTTYPA@UIAMVS.BITNET ("David A. Lyons") Newsgroups: comp.sys.apple Subject: getting CATALOG into text file--tested code + info Message-ID: <8901281524.aa11526@SMOKE.BRL.MIL> Date: 29 Jan 89 02:53:32 GMT Sender: daemon@ucbvax.BERKELEY.EDU Organization: The Internet Lines: 63 X-Unparsable-Date: Saturday 28 Jan 89 2:24 PM CT >Date: Tue, 24 Jan 89 19:12:00 GMT >From: Jerry Bauer >Subject: Getting a CATALOG into a file >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? To answer a different question first, if you want to do this in a utility program rather than from a program of your own, you can do it in Davex (Shareware, by me) with a command like: > whatever; cat /h2 The 'cat' command in Davex is very flexible, letting you sort the listing in various ways and show the contents of subdirectories. ------------- Applesoft itself doesn't have any disk-oriented commands. They are available under DOS 3.3 and BASIC.SYSTEM by PRINTing a Control-D (CHR$(4)) followed by a command. Buying _BASIC Programming with ProDOS_ from Addison-Wesley (APDA #A7Z0015, $29.95), would be a fairly intelligent thing to do, because the info you need is in there, and you'll be able to look it up a lot faster than you'll get complete responses on the net. (I'm a busy guy and am not always inclined to explain things that are already explained well in readily-available manuals.) Anyway, the following code has been tested: 50 DIM A$(200) 100 F$ = "whatever" 110 DIR$ = "/h2" 120 D$ = CHR$ (4) 200 PRINT D$;"open ";DIR$;",tDIR" 205 PRINT D$;"read ";DIR$ 210 I = I + 1: INPUT "";A$(I) 220 IF LEFT$ (A$(I),6) < > "BLOCKS" THEN 210 300 PRINT D$;"close ";DIR$ 310 PRINT D$;"open ";F$ 320 PRINT D$;"write ";F$ 330 FOR J = 1 TO I 340 PRINT A$(J) 350 NEXT J 360 PRINT D$;"close ";F$ The idea is to read the directory into an array until you come to the last line, which starts out "BLOCKS FREE:...", and then print the array back out to a text file. The size of the array is arbitrary, and a robust program will check that the array is about to be overflowed by a large directory rather than letting the program crash with a ?BAD SUBSCRIPT ERROR. >JRBauer (Jerry) ...!tolerant!procase!bauer > ...!hpda!procase!bauer > ...!cae780!procase!bauer --David A. Lyons bitnet: awcttypa@uiamvs DAL Systems CompuServe: 72177,3233 P.O. Box 287 GEnie mail: D.LYONS2 North Liberty, IA 52317 AppleLinkPE: Dave Lyons