Applesoft code to display filenames for use

6 posts / 0 new
Last post
Last seen: 8 months 1 week ago
Joined: Nov 12 2023 - 16:52
Posts: 1
Applesoft code to display filenames for use

I'm fairly proficient in Applesoft, but I cannot seem to find a way in basic to retrieve filenames from a disc catalog. 

I want to enable a user to pick from a selection of Binary files only, and then have their selection automatically loaded.

(These Binary files are text pg 1 files that have been saved).





Last seen: 3 days 3 hours ago
Joined: Jun 25 2020 - 17:00
Posts: 238
That's been a "wish" forever.

That's been a "wish" forever.


Unless someone has written custom code to perform this bit of retrieval magic, it cannot be done directly using Applesoft commands.

The "Beneath Apple DOS" by Don Worth and Pieter Lechner is a good reference for seeing what has to be done to satisfy your requirements.

This requires understanding DOS3.3 VTOC and CATALOG storage structures on a formatted floppy disk.

VTOC (Volume Table Of Contents) contains the first Catalog track/sector location, usually Track 11 (hex)/ sector 0F (hex).  VTOC only contains a table of allocated track/sectors used or unused for file storage.


Filenames appear in the Catalog's sector data.


Have fun!



Last seen: 3 days 3 hours ago
Joined: Jun 25 2020 - 17:00
Posts: 238
Wouldn't this be easier?

If you know the disk contents (filenames), why not save the names in a text file with each name terminated with a CR and therefore on a separate line in the text file.

Then display or write the text file contents to the screen in a numbered menu form for the use to select the desire file by selecting a number, i.e. 1, 2 , 3,  then BLOAD the file selected.


This could all be done in Applesoft code.


Last seen: 2 months 3 weeks ago
Joined: Jul 5 2018 - 09:44
Posts: 2587
Back in the day to do this I

Back in the day to do this I would write a small bit of code in assembly language that would use RWTS in DOS 3.3 to read in the disk catalog from track 11 and then parse it.  It's technically possible to do this from Applesoft of course but it's an awful lot of ugly CALL, POKE, PEEK  to set up the table for RWTS, read the sectors, retrieve all the data from memory...  It's a little more straighforward to do in assembler, but you've got to know what you're doing.  Anyway, the suggestion of Beneath Apple DOS (PDFs available online) is a good one.  Also, the Roger Wagner "Assembly Lines" book if I recall has code in there for some of this.  Look at back issues of SoftTalk magazine the DOS column (you can get them from  Also I remember learning from a few issues of CALL -A.P..P.L.E magazine which I think you can  get those online also, but not sure if they're free or you will have to pay Bill Martens/buy a membership.


Last seen: 3 days 3 hours ago
Joined: Jun 25 2020 - 17:00
Posts: 238
Apple Assembly Line by Bob

Apple Assembly Line by Bob Sander-Cederlof may also have insights and methods for doing this in assembly language.





Last seen: 3 months 3 weeks ago
Joined: Aug 15 2023 - 19:57
Posts: 9
A straightforward solution exists in ProDOS.

I believe, as others have stated, that no direct solution exists for DOS, and one must resort to low-level things via assembly.

However, for ProDOS, the following example snippet exists in the book "BASIC Programming With ProDOS" (which I'm fairly sure I obtained from archive dot org, but is probably on Asimov as well). I've modified the example to use the ProDOS 2.4.2 disk instead of an /EXAMPLES disk, and also to include line prefixes that "prove" the catalog listing is being seen by the running AppleSoft program, and not simply output directly to the user (as CHR$(4);"CATALOG" would do). The original program is found in Appendix D of that book, in a section entitled "Reading from ProDOS Directories".


5 D$ =  CHR$ (4)


20  PRINT D$;"READ /PRODOS.2.4.2"

30  INPUT L1$: PRINT "1:";L1$

40  INPUT L2$: PRINT "2:";L2$

50  INPUT L3$: PRINT "3:";L3$

60  INPUT L4$: PRINT "4:";L4$

70  IF L4$ <  > "" THEN  GOTO 60

80  INPUT L5$: PRINT L5$

90  PRINT D$;"CLOSE /PRODOS.2.4.2"


Note that at least 3 lines must be read before we start looking for a "terminating" blank line: The first line will be the prefix we're cataloging, the second will be table headers, the third is an intervening blank line before the actual file listing begins (which may be empty). After the next blank line (terminating the list of files), there is one more summary line to read before it's done (I didn't modify that line of the code to use a prefix).

Hope that helps!

Log in or register to post comments