Classic Computer Magazine Archive COMPUTE! ISSUE 67 / DECEMBER 1985 / PAGE 108

Apple ProDOS Disk Menu

K. Michael Parker

Here's a fast method of loading and running programs at the touch of a key. The program requires an Apple IIc or IIe with the ProDOS operating system.

How many times have you found yourself wishing for an easier way to load and run programs? The process of calling up a disk catalog, looking for the desired pathname, then typing (or mistyping) it can be a frustrating experience—especially if the pathname is something cryptic like FNINPT.BAO.2. Perhaps a better alternative is to select the program from a menu taken from the disk directory.

That's exactly what you can do with "ProDOS Disk Menu." To use it, create a startup disk by saving both ProDOS and BASIC.SYSTEM on a disk. Then save Disk Menu with the filename STARTUP.

When you boot this disk, a menu containing the first 16 programs in the directory appears on the 40-column screen. If more than 16 programs are on the disk, press P to view the next page. Pressing P on the last page returns you to the first page (Disk Menu accepts both uppercase and lowercase commands.)

If you don't find the program you want, press C. A screen prompt asks you to switch disks, then Disk Menu reruns itself.

To select a program, press the up/down arrow keys to position the cursor over the desired file-name, then press RETURN. A screen prompt offers three choices: (R)UN, (L)OAD, OR (U)NDO. If you made a mistake and selected the wrong program, press U to return to the menu.

Loading Multiple Programs

There are three ways to exit Disk Menu: run any program, load a BASIC program, or press Q to quit. Notice that loading a machine language program does not exit Disk Menu. Therefore, if you have a BASIC program that utilizes several ML subroutines, you could load the ML routines into memory one after the other, then exit DISK MENU by running the BASIC program.

The programming techniques used in Disk Menu are quite simple. The program retrieves the volume name from the disk and opens the volume directory. It reads the directory into an array, skipping all non-program files (except the type mentioned below). Then, depending on the current page, the program reads the filenames into the page array for display and selection.

A few parts of the program may need some explanation. For example, line 325 skips past the first few records on the volume directory, which do not contain information essential to the menu.

Disk Menu does not list any file types other than BASIC and binary files (.BAS and .BIN). Although data is sometimes stored in binary files, it is usually considered good practice to store data and programs on separate disks.

When writing Disk Menu, I was tempted to make it include files contained in subdirectories, but refrained because in my experience such files are usually chained to other programs, and would therefore only clutter up the menu. However, if you use subdirectories differently, the necessary alterations should be fairly simple.

Apple ProDOS Disk Menu

For instructions on entering this listing, please refer to "COMPUTE!'s Guide to Typing In Programs" published bimonthly in COMPUTE!.

51 10 D$ = CHR$ (4)
53 12 L = 1
E2 20 A$ (20) = "" : A$ (21) = "PRESS <RETURN> TO ACCEPT CHOICE" : A$(22) = "'Q' - QUIT" : A$ (23) = "'P' -PAGINATE 'C'-GET NEXT CATALOG"
44 100 HOME
54 110 INVERSE : PRINT "  D I S K   M E N U " : NORMAL
34 200 REM GET VOLUME LABEL
81 210 PRINT D$; "PREFIX/"
3A 220 PRINT D$; "PREFIX"
15 230 INPUT VL$
F7 240 PRINT D$
24 250 VTAB 2 : PRINT VL$: REM DISPLAY VOLUME NAME
ED 300 REM GET DIRECTORY
C9 310 PRINT D$; "OPEN";VL$;",TDI R"
D7 320 PRINT D$; "READ";VL$
DI 325 INPUT Z$ : INPUT Z$ : INPUT Z$
CC 330 INPUT L$(L)
DF 335 CH$ = MID$ (L$(L), 18, 3)
4E 340 IF L$(L) = "" THEN 360
FA 345 IF CH$ < > "BAS" AND CH$ < > "BIN" THEN 330
6A 350 L = L + 1 : GOTO 330
BF 360 PRINT D$; "CLOSE"
72 370 MAX = L - 1
75 400 PAGE = 0
F4 410 GOSUB 2000 : REM LOAD PAGE INTO ARRAY
52 420 GOSUB 3000 : REM PRINT ARRAY
FF 430 GOSUB 4000 : REM ACCEPT INPUT
F1 440 GOTO 5000 : REM RUN/LOAD
B6 2000 REM  INITIALIZE ARRAY
68 2010 FOR I = 4 TO 19 : A$ (I) = "" : HTAB 5 : VTAB I : PRINT SPC ( 16) : NEXT
27 2020 REM   LOAD PAGE INTO ARRAY
64 2030 N = PAGE * 16: PAGE = PAGE + 1
20 2040 IF (MAX - N) > = 16 THEN LIM = 16 : IF (MAX - N) = 16 THEN PAGE = 0
4D 2045 IF (MAX - N) < 16 THEN L IM = MAX - N : PAGE = 0
A5 2047 A = 4
Al 2050 FOR I = (N + 1) TO (N + LIM)
DB 2060 A$ (A) = L$ (I)
4B 2070 A = A + 1 : NEXT
F2 2080 RETURN
4D 3000 REM PRINT ARRAY
BB 3020 FOR I = 4 TO 19
76 3030 HTAB 5 : VTAB I
09 3040 PRINT MID$ (A$(I), 2, 16)
B7 3050 NEXT
C5 3060 FOR I = 21 TO 23 : VTAB I : PRINT A$(I) : NEXT
43 3062 CR = 4 : INVERSE : VTAB CR : HTAB 5 : PRINT MID$ (A$(CR), 2, 16) : NORMAL
A2 3065 VTAB CR : HTAB 4
EF 3070 RETURN
A3 4000 REM ACCEPT INPUT
53 4010 GET C$
3C 4020 IF C$ < > CHR$ (10) AND C$ < > CHR$ (11) AND C$ < > CHR$ (13) AND C$ < > "Q" AND C$ < > "C" AND C$ < > "q" AND C$ < > "c " AND C$ < > "P" AND C$ < > "p" THEN 4010
88 4030 IF C$ < > CHR$ (10) AND C4 < > CHR$ (11) THEN 4500
02 4040 REM MOVE CHOICE
5D 4050 VTAB CR : HTAB 5 : NORMAL : PRINT MID$ (A$(CR), 2, 16)
EF 4060 ON ASC (C$) - 9 GOSUB 4100,4200
BF 4070 INVERSE : VTAB CR : HTAB 5 : PRINT MID$ (A$(CR), 2, 16) : NORMAL
A7 4075 VTAB CR : HTAB 4
74 4080 GOTO 4010
D6 4100 REM DOWN
DA 4110 IF CR = 19 THEN CR = 3
D3 4120 IF CR < > 19 THEN CR = CR + 1
E2 4130 RETURN
77 4200 REM UP
6D 4210 IF CR = 4 THEN CR = 20
CD 4220 IF CR < > 4 THEN CR = CR - 1
E4 4230 RETURN
82 4500 IF C$ = "Q" OR C$ = "q" THEN HOME : END
2E 4510 IF C$ = "P" OR C$ = "p" THEN POP : GOTO 410
8D 4520 IF C$ = CHR$ (13) THEN RETURN : REM  LOAD/RUN SUBROTINE
02 4530 REM C$ MUST BE C OR c SO CONTINUE
CC 4540 HOME : INPUT "INSERT NEW DISK THEN PRESS <RETURN>";ANS$
7F 4550 POP : GOTO 10
21 5000 REM RUN/LOAD
A7 5002 FILE$ = MID$ (A$(CR), 2, 16) : TYPE$ = MID$ (A$(CR), 18, 3)
EA 5010 HTAB 5 : VTAB 3
B2 5020 PRINT " (R) UN, (L) OAD, OR (U)NDO" : HTAB 28 : VTAB 3
5D 5030 GET E$
55 5040 IF E$ < > "R" AND E$ < > "L" AND E$ < > "1" AND ES < > "r" AND ES < > "U" AND E$ < > "u" THEN 5030
DA 5045 HTAB 5 : VTAB 3 : PRINT ""
50 5047 IF E$ = "U" OR E$ = "u" THEN PAGE = 0: GOTO 410
7F 5050 IF E$ = "L" OR E$ = "1" THEN 5100
9E 5060 HOME : PRINT D$;"-";FILE$
17 5070 NEW
E0 5100 IF TYPE$ = "BAS" THEN HOME : PRINT D$;"LOAD";FILE$
44 5110 IF TYPE$ = "BIN" THEN PRINT D$;"BLOAD";FILE$
D9 5120 GOTO 420