10 '
20 ' DO NOT RENUM OR RENAME OR COMPILE THIS PROGRAM.
30 '
40 ' BASIC MENU PROGRAM. VERSION 1.0
50 ' A MAXIMUM OF 112 BASIC FILES WILL BE HANDLED BY THIS PROGRAM.
60 ' SEE BMENU.DOC FOR MORE INFORMATION. BOB STEPHENS  SAN JOSE 12/1/82
70 DEFINT A-Z:DIM ARRAY$(113)
80 DEF SEG=0:MN=PEEK(&H410) AND &H30:IF MN=&H30 THEN MN=1 ELSE MN=0
90 SCREEN 0:IF MN=0 THEN COLOR 14,1,4 ELSE COLOR 7,0
110 KEY OFF :KEY 10,"RUN"+CHR$(34)+"BMENU"+CHR$(13)
120 KEY 1,"UPDATE":KEY 2,"HELP":KEY 3,"BASIC":KEY 4,"DOS":KEY 5,"DATE"
130 KEY(1) ON:KEY(2) ON:KEY(3) ON:KEY(4) ON:KEY(5) ON
140 ON KEY(1) GOSUB 1210:ON KEY(2) GOSUB 1670:ON KEY(3) GOSUB 1730
150 ON KEY(4) GOSUB 1740:ON KEY(5) GOSUB 1720:KEY ON
160 ' THE FOLLOWING STATEMENTS WILL BE MODIFIED WITH F1
500 'BEGIN
505 KEY OFF
510 CLS:COLOR 0,7: PRINT "         PROGRAM INFORMATION         ":COLOR 7,0
520 PRINT "This program provides a sorted menu"
530 PRINT "display of the BASIC programs on your"
540 PRINT "diskette and allows for menu selected"
550 PRINT "execution of the BASIC programs."
560 PRINT " "
570 PRINT "Function key F1 is used whenever BASIC"
580 PRINT "programs are added or deleted from the"
590 PRINT "diskette. While F1 is slow to"
600 PRINT "execute the result will be a high"
610 PRINT "performance (for BASIC) menu program."
620 PRINT "F1 will create and kill file"
630 PRINT "BMENU.TMP and will modify itself."
640 PRINT "Be sure the default drive (set by DOS)"
650 PRINT "is the same as the drive containing"
660 PRINT "the menu program. See BMENU.DOC."
670 PRINT
680 COLOR 0,7:PRINT "Do not renum or change the name of this"
690 PRINT "program. This message will self        "
700 PRINT "destruct (forever) when you ENTER.     ":COLOR 7,0:PRINT
710 PRINT "          BOB STEPHENS SAN JOSE 12/1/82"
720 PRINT
730 INPUT "Press ENTER to continue...",A$
740 GOTO 1210
999 ' END
1000 ' END OF MODIFIED AREA
1005 CLS:IF ARRAY$(64)="" THEN WIDTH 40 ELSE WIDTH 80
1010 P=0:I=0:CLS:LOCATE 1,4:COLOR 14,0
1020 PRINT "BASIC programs on this diskette:"
1030 FOR DC=1 TO 66 STEP 13
1040  FOR DR=3 TO 23
1050   I=I+1
1060   IF ARRAY$(I)="" THEN 1130 ELSE LOCATE DR,DC
1070   IF MN=1 THEN COLOR 0,7 ELSE COLOR 1,14,4
1080   PRINT USING "###";I;
1090   IF MN=1 THEN COLOR 7,0 ELSE COLOR 14,1,4
1100   PRINT " ";ARRAY$(I)
1110  NEXT DR
1120 NEXT DC
1130 LOCATE 24,1,1,7,11:PRINT "Enter number of program desired: ";:B$=""
1140 A$=INKEY$:IF A$="" THEN 1140 ELSE IF ASC(A$)=13 THEN 1160
1150 IF (ASC(A$)<48) OR (ASC(A$)>57) THEN 1130 ELSE PRINT A$;:B$=B$+A$:GOTO 1140
1160 P=VAL(B$):IF P < 1 OR P >= I THEN 160
1170 WIDTH 80:CLS:PRINT "Press F10 to return to menu when finished"
1180 PRINT "or enter RUN";:PRINT CHR$(34);:PRINT "BMENU if F10 is changed."
1190 GOSUB 1650:ON ERROR GOTO 1750:RUN ARRAY$(P)
1200 ' MENU UPDATE AREA
1210 WIDTH 80:ON ERROR GOTO 1620
1220 KILL "BMENU.TMP"
1230 ON ERROR GOTO 0
1240 CLS:FILES "*.BAS":AR=0
1250 PRINT:PRINT:PRINT "Reading files":PRINT
1260 FOR I=1 TO 113
1270  ARRAY$(I)=""
1280 NEXT I
1290 FOR DR=1 TO 24
1300  FOR DC=0 TO 65 STEP 13
1310   IF CHR$(SCREEN(DR,DC+1)) = " " THEN 1390
1320   AR=AR+1:IF AR=113 THEN PRINT "To many files":END
1330   FOR L=1 TO 8
1340    ARRAY$(AR)=ARRAY$(AR)+CHR$(SCREEN(DR,DC+L))
1350   NEXT L
1360  NEXT DC
1370 NEXT DR
1380 ' SORT
1390 CKSW=1:PRINT "Sorting in BMENU.TMP";
1400 WHILE CKSW=1:CKSW=0
1410  FOR I=2 TO AR
1420   IF ARRAY$(I-1)>ARRAY$(I) THEN CKSW=1:SWAP ARRAY$(I-1),ARRAY$(I)
1430  NEXT I
1440 WEND
1450 ON ERROR GOTO 1580
1460 OPEN "BMENU.TMP" FOR OUTPUT AS #1
1470 ON ERROR GOTO 0
1480 PRINT #1,"500 'BEGIN"
1490 FOR I=1 TO AR
1500  PRINT #1,STR$(I+500) + " ARRAY$(" + STR$(I) + " )=" + CHR$(34) + ARRAY$(I) + CHR$(34)
1510 NEXT I
1520 PRINT #1,"999 'END"
1530 ON ERROR GOTO 1630
1540 CLOSE
1550 CHAIN MERGE "BMENU.TMP",1560,ALL,DELETE 500-999
1560 KILL "BMENU.TMP":SAVE "BMENU
1570 RUN"BMENU
1580 IF (ERR=70) AND (ERL=1460) THEN RESUME 1590 ELSE ON ERROR GOTO 0
1590 CLS:PRINT "The disk is write protected!"
1600 PRINT "Remove tab and press F10 or abort the program.":PRINT
1610 GOSUB 1650:END
1620 IF (ERR=53) AND (ERL=1220) THEN RESUME NEXT ELSE ON ERROR GOTO 0
1630 IF (ERR=5) AND (ERL=1550) THEN RESUME 1640 ELSE ON ERROR GOTO 0
1640 ON ERROR GOTO 0:CHAIN MERGE "BMENU.TMP",1560,ALL:GOTO 1560
1650 KEY OFF:KEY 1,"LIST ":KEY 2,"RUN"+CHR$(13):KEY 3,"LOAD"+CHR$(34)
1660 KEY 4,"SAVE"+CHR$(34):KEY 5,"CONT"+CHR$(13):KEY ON:RETURN
1670 CLS:PRINT "Exit to DOS and enter TYPE BMENU.DOC to"
1680 PRINT "display the information distributed"
1690 PRINT "with this program."
1700 ON ERROR GOTO 0:PRINT:PRINT "Press any key to continue...";
1710 A$=INKEY$:IF A$="" THEN 1710 ELSE RETURN 90
1720 CLS:PRINT:PRINT "DATE: " DATE$ "   TIME: " TIME$:GOTO 1700
1730 WIDTH 80:GOSUB 1650:END
1740 SYSTEM
1750 IF (ERR=53) AND (ERL=1190) THEN GOTO 1760 ELSE ON ERROR GOTO 0
1760 PRINT:PRINT "File " ARRAY$(P) ".BAS not found":RESUME 1700