bauer@procase.UUCP (Jerry Bauer) (01/25/89)
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?) I suspect that answers to this question are of general interest; but if you disagree, just send them to me JRBauer (Jerry) ...!tolerant!procase!bauer ...!hpda!procase!bauer ...!cae780!procase!bauer -- JRBauer (Jerry) ...!tolerant!procase!bauer ...!hpda!procase!bauer ...!cae780!procase!bauer
delaneyg@wnre.aecl.CDN (01/25/89)
First a suggestion. Get a copy of BASIC PROGRAMMING IN PRODOS. Your book or computer stores should have it APPLE wrote it Adison Wesely Publish it it has a disk included. To get a quick fix do some thing like this. 10 D$ = CHR$(4) 20 INPUT "DIRECTORY NAME NO / ALLOWED "; A$ 30 ?D$;"OPEN ";A$;",TDIR" 40 ?D$;"READ ";A$;" 50 INPUT R1$:?R1$:REM HEADER 60 INPUT R2$:?R2$:REM BLANK LINE 70 INPUT R3$:?R3$:REM BLANK LINE 80 INPUT R4$:?R4$ 90 IF R4$ <> "" THEN 80 100 INPUT R5$:?R5$ 110 ?D$;"CLOSE ";A$ This will just print it to the screen what you have to do is the write it to the disk as a text file. A hint the records are formated I don't have it hear but it's easy to count out. You can use MID$ or Right$ or LEFT$ to just WRITE what you want. Grant
jm7e+@ANDREW.CMU.EDU ("Jeremy G. Mereness") (01/25/89)
Jerry Bauer writes..... >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?) Catalog is not an Applesoft command; it is not contained in the ROMS that contain Applesoft. So, Applesoft attpempts to interpret the command as best it can (thus breaking it into "c at a log" where "at" and "log" are reserved keywords.... What you want to do whenver you want to issue a ProDos command from within Applesoft is PRINT the command and precede the command with a CTRL-D. It looks like this.. 120 PRINT "<Ctrl-D>CATALOG" or better yet 120 PRINT CHR$(4);"CATALOG" where CHR$(4) is the same as Ctrl-D. This works for all Prodos commmands, and BTW if you ever use DOS 3.3, you should precede the Ctrl-D with a linefeed, like 120 PRINT CHR$(13);CHR$(4);"CATALOG" : REM dos 3.3 only Capt. Albatross jm7e+@andrew.cmu.edu ============ Bureuacracy takes all the fun out of computing. disclaimer: The opinions expressed herein are made under duress of academic stress and is often prone to overzealous error. The author, not enjoying the prospect of remaining eternally ignorant, therefore welcomes any replies that would further that end.
ART100@PSUVM.BITNET ("Andy Tefft 862-6728", 814) (01/26/89)
Well, I haven't tried this out, but you DO have to use PRINT CHR$(4)"CATALOG" instead of using just CATALOG, as you do with all DOS 3.3 or ProDOS commands in programs. You can also read the directory in as a binary file, BLOAD dirname,A$addr,TDIR (of course this assumes you entered it from the keyboard; don't forget the ?CHR$(4)!) and then try to decode the information from that... I do remember I figured out how to get the root directory this way, or I think I did, but can't remember what to use as the file name...
nuroehri@ndsuvax.UUCP (Dean Roehrich) (01/26/89)
In article <410f8301.14dd6@c> bauer@procase.UUCP (Jerry Bauer) writes: > >Under ProDOS, in APPLESOFT, how can one get a list of the files on >a given disk (CATALOG) into a file? > >-- >JRBauer (Jerry) ...!tolerant!procase!bauer > ...!hpda!procase!bauer > ...!cae780!procase!bauer Under ProDOS, _any_ file, including a directory, can be opened like a text file and read with the READ statement. d$=chr$(4) dim i$(10) print d$"open <dirname>" print d$"read <dirname>" for i = 0 to 10 read i$(i) next print d$"close" The variable I$() should now hold the first 11 lines of the directory. This would include the directory name, the blank space, the header, filenames, the blank space, and the footer (if I got all the right). Dean #! rnews 1551 Path: psuvm.bitnet!cunyvm!
patrick@chinet.chi.il.us (Patrick A. Townson) (01/26/89)
In article <410f8301.14dd6@c> bauer@procase.UUCP (Jerry Bauer) writes: >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 > You might write line 120 to say PRINT CHR$(4)"CATALOG". Issuing it that way will prevent the inappropriate parsing. You might also write line 120 to say CALL XXXXX, where XXXXX is the pro-DOS location for the catalog routine. (In DOS 3.3, 'call 42350' will do a catalog. I do not know what the pro-DOS location would be.) >(Isn't APPLESOFT wonderful?) Yep. It sure is. I've used it for years in programming on my Bell & Howell Apple 2+ (the 'black apples'). I have yet to find something I wanted to do which could not be programmed easily using a combination of Applesoft, Calls, and a little assembly code. In fact I do what assembly is required right in the APPLESOFT program itself with POKES. Or sometimes I write a short routine at 768 to interact with Applesoft as required. Applesoft does require a little imagination at times, and a good working knowledge of how it goes about its business is important. By the way, I would also suggest one other change when you write that catalog to a file: If you have a long catalog, it is going to pause after about a screenful and wait for a keypress, which it will never find since the computer is getting its input from the disk. To temporarily suspend catalog pause (that is, to play the entire catalog without stopping after a screen) -- 115 FOR LOOP=44596 TO 44598: POKE LOOP,234: NEXT LOOP: REM You have to NOP those three instructions which cause the catalog to pause. 125 POKE 44596,206: POKE 44597,157: POKE 44598,179: REM To restore DOS to normal operation where catalog pausing is concerned. Again, the above applies to DOS 3.3. You would need to substitute Pro-DOS locations. But the need for the adjustment is the same using either DOS I believe. Patrick -- Patrick Townson patrick@chinet.chi.il.us / US Mail: 60690-1570 (personal zip code) FIDO: 115/743 / AT&T Mail: 529-6378 (!ptownson) / MCI Mail: 222-4956
jetzer@studsys.mu.edu (jetzer) (01/26/89)
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."
matthew@sunpix.UUCP ( Sun NCAA) (01/27/89)
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?)
#
#
# I suspect that answers to this question are of general interest;
# but if you disagree, just send them to me
#
# JRBauer (Jerry) ...!tolerant!procase!bauer
# ...!hpda!procase!bauer
# ...!cae780!procase!bauer
#
Your first mistake is to try and execute a BASIC.SYSTEM command from
within a running program with PRINTING it like you did in lines 100, 110
and 130. Secondly, I don't think your snippit of code would work as
desired, even if you did correct it.
Now mind you, I haven't tried this yet, but I think you need to do the
following (written in pseudo code)
"OPEN /DISKNAME" REM open file using directory name
"OPEN TEMP.CATALOG" REM open text file to put the retrieved CAT
ONERROR GOTO ENDRD REM set ONERROR to trap end of file
RDLOOP "READ /DISKNAME" REM set input to directory name
READ A$ REM and get a line it
"WRITE TEMP.CATALOG" REM set output to file
PRINT A$ REM and send a line to it
GOTO RDLOOP REM keep doing it until done
ENDRD "CLOSE" REM close all open files
I used a error detection to trap the end of file in this example. But
you could also try testing for a string in the last line of the catalog, and
exit the loop before getting the end of file error.
--
Matthew Lee Stier (919) 469-8300|
Sun Microsystems --- RTP, NC 27560| "Wisconsin Escapee"
uucp: {sun, rti}!sunpix!matthew |
erast1@cisunx.UUCP (Evan Ron Aussenberg) (01/27/89)
In article <8901251315.aa00307@SMOKE.BRL.MIL> ART100@PSUVM.BITNET ("Andy Tefft 862-6728", 814) writes: >Well, I haven't tried this out, but you DO have to use > >PRINT CHR$(4)"CATALOG" > >instead of using just CATALOG, as you do with all DOS 3.3 or ProDOS commands >in programs. > >You can also read the directory in as a binary file, > >BLOAD dirname,A$addr,TDIR (of course this assumes you entered it from > the keyboard; don't forget the ?CHR$(4)!) > >and then try to decode the information from that... C'mon now... lets make things easier than that. I haven't used AppleSoft in a long time but I remember something like the following should work. 100 d$=chr$(4) 102 fi$ = "Your.catalog" 105 : 110 print d$"prefix": input p$: REM: Optional, get the current prefix 120 print 125 print "This is the directory of "; 130 inverse: print p$;: normal: print 140 : 150 print d$"open "p$",TDIR" 160 for x=1 to 3: gosub 500: gosub 600: next: REM: input the headers 162 REM: of the catalog. 165 gosub 500: gosub 600: REM - Keep inputing lines as long 170 if len(dir$) > 0 then 165: REM - as they aren't blank. 175 : 180 gosub 500: gosub 600: REM - get the last line 185 : 190 print d$"close" 200 END 300 : 400 REM --------------------------------------------------------------- 450 : 480 : 500 print d$"read "p$ REM - A subroutine to read a catalog line 502 input dir$: print dir$ 505 RETURN 510 : 600 print d$"write "fi$ REM - A subr. to send a catalog to a file 605 print dir$ 610 RETURN Hope this works... any errors are free of charge. Evan Ron Aussenberg - erast1@unix.cis.pittsburgh.edu PS - One final note. If you're prefixing /ram get rid of line 180, for some reason (someone more technical than I am can say...), I can't seem to read the 'BLOCKS FREE' line from there. I haven't tried it on /ram5 with my GS though, so I don't know if it's a problem just with /ram or with RAM disks in general. Could never figure that one out...
erast1@cisunx.UUCP (Evan Ron Aussenberg) (01/27/89)
In article <15354@cisunx.UUCP> erast1@unix.cis.pittsburgh.edu (Evan Ron Aussenberg) writes: > 140 : > 150 print d$"open "p$",TDIR" > >Hope this works... any errors are free of charge. Ha, shouldn't have trusted me! Add line: 155 print d$"open "fi$ >Evan Ron Aussenberg - erast1@unix.cis.pittsburgh.edu (same)
jb10320@uxa.cso.uiuc.edu (01/30/89)
Doing a OPEN FILE WRITE FILE CATALOG CLOSE For some reason drops DOS 3.3 into the monitor. For a long time I tried in vain to get this kind of thing to work, doing all sorts of wierd things like custom input vectors to directly store screen output in other memory. Nothing worked, so I assumed it was DOS's fault (now I realize that I was probably forcing DOS to be re-entrant and recursive, something it definitely was NOT built to do) jawaid bazyar