1000 '"AUTOST" Loads keys, Sets Date & Time if not set by battery clock,
1010 'Displays Disk ID & File Directory and RUNS Program
1020 PROG1$="       A U T O S T A R T       "' BY Robert H. Hamilton
1030 REV$ = "          Rev: 830120          "
1040 YR$="1983":DISKID$="":SCREEN 0,0,0:WIDTH 80:COLOR 2,0,0
1050 LOCATE ,,1,12,13:DEF SEG=0:IF PEEK (&H410)= 109 THEN LOCATE ,,,6,7
1060 CL$=STRING$(79,0):Q$=CHR$(34):DEF SEG=64:POKE 23,128:DEF SEG:GOTO 1220
1070      REM: ?? KEYS
1080 KEY OFF: KEY 1,CHR$(27)+"CLS:LIST  "
1090 KEY 2,CHR$(27)+"RUN "+CHR$(7):KEY 3,CHR$(27)+"LOAD"+CHR$(7)+CHR$(34)
1100 KEY 4,CHR$(27)+"SAVE "+CHR$(34): KEY 5,CHR$(27)+"RUN"+CHR$(7)+CHR$(34): KEY 6,CHR$(27)+"GOTO 1000"
1110 KEY 7,CHR$(27)+CHR$(12)+"FILES "+CHR$(34)+"A:*.*":KEY 8,CHR$(27)+"RENUM 1000"
1120 KEY 9,CHR$(12)+"COLOR 6,0:CLS"+CHR$(13) : KEY 10,CHR$(27)+"RUN"+CHR$(34)+"AUTOST"+CHR$(7)
1130 FOR I=1 TO 10:ON KEY(I) GOSUB 0:KEY(I) ON:NEXT  'Optional, Requires Basica
1140      REM: ?? TITLE
1150 CLS:LOCATE 1,25:PRINT CHR$(213)+STRING$(31,205)+CHR$(184)
1160 PRINT TAB(25);CHR$(179);:COLOR 6,0:PRINT PROG1$;:COLOR 2,0:PRINT CHR$(179)
1170 IF DRIVE=1 THEN PRINT "DIRECTORY: Disk B";TAB(25);CHR$(179)+REV$;CHR$(179);TAB(62);"DATE: ";DATE$:GOTO 1190
1180 PRINT "DIRECTORY: Disk A";TAB(25);CHR$(179)+REV$;CHR$(179);TAB(62);"DATE: ";DATE$
1190 PRINT TAB(25);CHR$(212)+STRING$(31,205)+CHR$(190);TAB(62);"TIME: ";LEFT$(TIME$,5);SPC(2);MID$(TIME$,6,3)
1200 RETURN
1210      REM: ?? START program
1220 GOSUB 1080:GOSUB 1780: IF RIGHT$(DATE$,2)<"82" THEN GOSUB 1990:GOSUB 1080
1230 ON ERROR GOTO 1900
1240  LOCATE 5,1,1:PRINT "DISK ID:   ";DISKID$:COLOR 10,0
1250 DL$="File====.Ext ":PRINT DL$;DL$;DL$;DL$;DL$;DL$:COLOR 6,0
1260 IF DRIVE=1 THEN FILES"B:*.*":GOTO 1280
1270 FILES "*.*"
1280 LOCATE 25,1
1290 COLOR 0,7 :PRINT " FILENAME "; : COLOR 5,0 :PRINT " to Run  ";
1300 COLOR 0,7 :PRINT " ENTER ";:COLOR 5,0: PRINT " Dir A  ";
1310 COLOR 0,7 :PRINT " ?B ";:COLOR 5,0: PRINT " Dir B  ";
1320 COLOR 0,7 :PRINT " ! "; :COLOR 5,0 :PRINT " Basic  ";
1330 COLOR 0,7 :PRINT " | "; :COLOR 5,0 :PRINT " Disk ID  ";
1340 COLOR 0,7 :PRINT " Q "; :COLOR 5,0 :PRINT " DOS";
1350 IF ERFLAG=1 THEN LOCATE 23,5:COLOR 12,0:PRINT Q$;FILE$;Q$;"  is Not A Basic Program";
1360 LOCATE 24,1:COLOR 10,0:PRINT "RUN ";CHR$(34);"        .BAS";CHR$(34);:LOCATE 24,6
1370 COLOR 6,0:INPUT"",FILE$: COLOR 6,0:ERFLAG=0:DRIVE=0:DR$="Drive A "
1380 IF FILE$="" THEN 1000
1390 UPC$=FILE$:GOSUB 2470:FILE$=UPC$
1400 IF LEFT$(FILE$,2)="B:" THEN DR$="Drive B "
1410 IF FILE$="?" OR FILE$="?A" OR FILE$="?A:" THEN 1000
1420 IF FILE$="?B" OR FILE$="?B:" THEN DRIVE=1:DR$="Drive B ":GOTO 1000
1430 IF INSTR(FILE$,"?")<>0 THEN ERFLAG=1:GOTO 1000
1440 IF INSTR(FILE$,".EXE")<>0 THEN ERFLAG=1:GOTO 1000
1450 IF INSTR(FILE$,".COM")<>0 THEN ERFLAG=1:GOTO 1000
1460 IF INSTR(FILE$,".BAT")<>0 THEN ERFLAG=1:GOTO 1000
1470 IF INSTR(FILE$,".DOC")<>0 THEN ERFLAG=1:GOTO 1000
1480 IF INSTR(FILE$,".REV")<>0 THEN ERFLAG=1:GOTO 1000
1490 DEC=INSTR(FILE$,".")
1500 IF FILE$="|" THEN 1570
1510 IF FILE$="!" THEN 1960
1520 IF FILE$="Q" THEN COLOR 6,0:CLS:LOCATE 24,1:SYSTEM
1530 IF DEC=0 THEN FILE$=FILE$+".BAS"
1540 ON ERROR GOTO 1880
1550 CLS:LOCATE 25,1:PRINT"WAIT - Loading ";CHR$(34);FILE$;CHR$(34)
1560 LOAD FILE$,R: END
1570      REM: ?? EDIT DISK ID
1580 CLS:LOCATE 25,1
1590 COLOR 0,7:PRINT" ENTER ";:COLOR 5,0:PRINT" To accept description   ";
1600 COLOR 0,7:PRINT" DESCRIPTION ";:COLOR 5,0:PRINT" For new data   ";
1610 COLOR 0,7:PRINT" Q ";:COLOR 5,0:PRINT" To Abort";
1620 LOCATE 17,1:COLOR 6,0:PRINT"DISK A:":ON ERROR GOTO 1730 :GOSUB 1790:LOCATE 19,1
1630 PRINT "DISK ID: ";DISKID$:COLOR 5,0:PRINT "Change:  ";:LOCATE ,10:LINE INPUT"",DSK$
1640 IF LEN(DSK$)>66 THEN BEEP:PRINT"Disk ID too long";CHR$(10): GOTO 1630
1650 IF DSK$<>"" THEN DISKID$=DSK$
1660 IF DSK$="q" OR DSK$="Q" THEN 1000
1670 COLOR 6,0:PRINT CHR$(10);"YEAR:    ";YEAR$:COLOR 5,0:PRINT"Change:  " ;:INPUT"",Y$: IF Y$="" THEN 1710
1680 IF Y$="q" OR Y$="Q" THEN 1000
1690 IF VAL(Y$)<1983 OR VAL(Y$)>1999 OR LEN(Y$)>4 THEN BEEP: GOTO 1670
1700 YEAR$=Y$
1710 OPEN "diskid.rev" FOR OUTPUT AS #1
1720 PRINT #1,DISKID$: PRINT#1,YEAR$:CLOSE #1:GOTO 1000
1730 IF ERR=52 OR ERR=53 THEN RESUME 1630
1740 IF ERR=70  THEN RESUME 1940
1750 IF ERR=71  THEN RESUME 1950
1760 COLOR 12,0:CLS:LOCATE 23,1:KEY ON:COLOR 6,0:ON ERROR GOTO 0
1770      REM: ?? READ DISK ID
1780 ON ERROR GOTO 1830
1790 IF DRIVE=1 THEN DISKID$="":OPEN "B:diskid.rev" FOR INPUT AS #1:GOTO 1810
1800 DISKID$="":OPEN "diskid.rev" FOR INPUT AS #1
1810 LINE INPUT#1,DISKID$:INPUT #1,YEAR$:CLOSE #1
1820 RETURN
1830 IF ERR=62 THEN RESUME NEXT
1840 IF ERR=53 THEN RESUME 1820
1850 IF ERR=70 THEN RESUME 1940
1860 IF ERR=71 THEN RESUME 1950
1870 COLOR 12,0:CLS:LOCATE 23,1:KEY ON:BEEP:COLOR 6,0:ON ERROR GOTO 0
1880      REM: ?? ERROR out
1890 IF ERR=52 OR ERR=53 OR ERR=64 OR ERR=66 THEN ERFLAG=1:RESUME 1000
1900 IF ERR=53 OR ERR=64 THEN RESUME NEXT
1910 IF ERR=70 THEN RESUME 1940
1920 IF ERR=71 THEN RESUME 1950
1930 COLOR 12,0:CLS:LOCATE 24,1:KEY ON:BEEP:COLOR 6,0:ON ERROR GOTO 0: END
1940 COLOR 12,0:CLS:LOCATE 21,1:BEEP:PRINT"Disk is Write Protected:  ENTER to Continue";:INPUT;"",ZZ$:RUN
1950 COLOR 12,0:CLS:LOCATE 21,1:BEEP:PRINT DR$;"Not Ready: Correct and  ENTER to Continue";:INPUT;"",ZZ$:RUN
1960      REM: ?? CLEAR
1970 COLOR 12,0:CLS:LOCATE 21,1:PRINT"NOTE: Enter NEW before writing a new program":KEY ON:COLOR 6,0:END
1980      REM: ?? SET Date and Time
1990 CLR$=STRING$(79,0):IF YEAR$="" THEN YEAR$=YR$
2000 MO$="":DAY$="":HR$="":MIN$="":DAT$="":TM$=""
2010 LOCATE 23,1:PRINT CLR$;:LOCATE 23,1:ON ERROR GOTO 2440:AM=0:PM=0
2020 COLOR 0,7:PRINT" ENTER ";:COLOR 5,0:PRINT" Month No, Day and Time (Mo Da Time) am/pm or 24 hour";
2030 BEEP:LOCATE 24,1:PRINT CLR$;:LOCATE 24,1:COLOR 6,0:PRINT "Example: 3-15-230p";TAB(33);:COLOR 12,0::LINE INPUT;"",DT$:COLOR 6,0:IF DT$="" THEN 2450
2040 IF RIGHT$(DT$,1)=" " OR RIGHT$(DT$,1)="." THEN DT$=MID$(DT$,1,LEN(DT$)-1):GOTO 2040 'Right trim
2050 IF RIGHT$(DT$,1)="p" OR RIGHT$(DT$,1)="P" THEN PM=1
2060 IF MID$(DT$,LEN(DT$)-1,1)="p" OR MID$(DT$,LEN(DT$)-1,1)="P" THEN PM=1
2070 IF MID$(DT$,LEN(DT$)-2,1)="p" OR MID$(DT$,LEN(DT$)-2,1)="P" THEN PM=1
2080 IF RIGHT$(DT$,1)="a" OR RIGHT$(DT$,1)="A" THEN AM=1
2090 IF MID$(DT$,LEN(DT$)-1,1)="a" OR MID$(DT$,LEN(DT$)-1,1)="A" THEN AM=1
2100 IF MID$(DT$,LEN(DT$)-2,1)="a" OR MID$(DT$,LEN(DT$)-2,1)="A" THEN AM=1
2110 FOR I=1 TO LEN(DT$)
2120 IF MID$(DT$,I,1)="" THEN 2150
2130 IF ASC(MID$(DT$,I,1))<48 OR ASC(MID$(DT$,I,1))>57 THEN MID$(DT$,I,1)=" "
2140 NEXT
2150 IF ASC(DT$)<48 OR ASC(DT$)>57 THEN DT$=MID$(DT$,2): GOTO 2150 'Left trim
2160 MO$=LEFT$(DT$,1): IF LEN(DT$)=1 THEN 2450
2170 IF ASC(MID$(DT$,2,1))>47 AND ASC(MID$(DT$,2,1))<58 THEN MO$=MID$(DT$,1,2)
2180 DT$=MID$(DT$,LEN(MO$)+1)
2190 IF ASC(DT$)<48 OR ASC(DT$)>57 THEN DT$=MID$(DT$,2): GOTO 2190 'Left trim
2200 DAY$=LEFT$(DT$,1): IF LEN(DT$)=1 THEN 2440
2210 IF ASC(MID$(DT$,2,1))>47 AND ASC(MID$(DT$,2,1))<58 THEN DAY$=MID$(DT$,1,2)
2220 DT$=MID$(DT$,LEN(DAY$)+1)
2230 IF ASC(DT$)<48 OR ASC(DT$)>57 THEN DT$=MID$(DT$,2): GOTO 2230 'Left trim
2240 IF ASC(RIGHT$(DT$,1))<48 OR ASC(RIGHT$(DT$,1))>57 THEN DT$=MID$(DT$,1,LEN(DT$)-1):GOTO 2230 'Right trim
2250 IF LEN(DT$)<3 THEN 2440
2260 FOR I=1 TO LEN(DT$)
2270 IF MID$(DT$,I,1)="" THEN 2300
2280 IF ASC(MID$(DT$,I,1))<48 OR ASC(MID$(DT$,I,1))>57 THEN DT$=MID$(DT$,1,I-1)+MID$(DT$,I+1)
2290 NEXT:IF LEN(DT$)<3 THEN 2450
2300 HR$=MID$(DT$,1,LEN(DT$)-2):MIN$=RIGHT$(DT$,2)
2310 IF PM=1 AND VAL(HR$)<12 THEN HR$=STR$(VAL(HR$)+12)
2320 IF PM=1 AND VAL(HR$)=12 AND VAL(MIN$)=0 THEN HR$="00"
2330 IF VAL(HR$)=24 AND VAL(MIN$)=0 THEN HR$="00"
2340 IF AM=1 AND VAL(HR$)=12 AND VAL(MIN$)>0 THEN HR$="00"
2350 IF ASC(HR$)<48 OR ASC(HR$)>57 THEN HR$=MID$(HR$,2): GOTO 2350 'Left trim
2360 IF VAL(DAY$)<1 OR VAL(DAY$)>31 THEN 2450
2370 IF VAL(MO$)<1 OR VAL(MO$)>12 THEN 2450
2380 IF VAL(HR$)<0 OR VAL(HR$)>24 THEN 2450
2390 IF VAL(MIN$)<0 OR VAL(MIN$)>59 THEN 2450
2400 IF VAL(HR$)*100+VAL(MIN$)>2400 THEN 2450
2410 DAT$=MO$+"-"+DAY$+"-"+YEAR$
2420 TM$=HR$+":"+MIN$
2430 DATE$=DAT$:TIME$=TM$: RETURN
2440 RESUME 2450
2450 LOCATE 21,1:PRINT CLR$;:LOCATE 21,1:COLOR 12,0:PRINT"ERROR: Please enter again";: GOTO 2010
2460 END
2470      REM:  ?? UPPERCASE
2480   FOR I=1 TO 30:IF MID$(UPC$,I,1)="" THEN RETURN
2490   UPC=ASC(MID$(UPC$,I,1))
2500   IF UPC>96 AND UPC<123 THEN MID$(UPC$,I,1)=CHR$(UPC-32)
2510   NEXT:RETURN
2520 END