mirror of
https://github.com/gungwald/prodos-more.git
synced 2024-08-31 11:29:36 +00:00
90 lines
3.6 KiB
QBasic
90 lines
3.6 KiB
QBasic
10 REM *****************************
|
|
15 REM * *
|
|
20 REM * MORE - TEXT FILE VIEWER *
|
|
30 REM * AUTHOR - BILL CHATFIELD *
|
|
35 REM * *
|
|
40 REM *****************************
|
|
44 :
|
|
45 REM TODO:
|
|
46 REM CD,PREFIX,PWD,CWD,CHDIR,FASTER OUTPUT
|
|
47 REM PREFIX IN PROMPT
|
|
48 REM DETAILED HELP FROM "?" COMMAND, FIX FIRST LINE
|
|
49 :
|
|
50 LET D$ = CHR$ (4)
|
|
55 LET BS$ = CHR$ (7)
|
|
56 LET CR$ = CHR$ (13)
|
|
57 LET PROMPT$ = "[RETURN] NEXT LINE [SPACE] NEXT PAGE [Q] QUIT"
|
|
58 LET LINE = 1
|
|
59 PRINT "ENTER A FILE NAME, * FOR CATALOG, OR JUST HIT RETURN TO ABORT
|
|
."
|
|
60 INPUT "FILE:";F$
|
|
70 IF RIGHT$ (F$,1) = "*" THEN PRINT D$;"CATALOG "; LEFT$ (F$, LEN (F
|
|
$) - 1): GOTO 60
|
|
80 IF F$ = "" THEN END
|
|
85 IF F$ = "?" THEN 59
|
|
110 ONERR GOTO 5050: REM SETUP ERROR HANDLER
|
|
125 PRINT D$;"VERIFY ";F$: REM CHECK IF FILE EXISTS, ERROR CODE 6
|
|
130 PRINT D$;"OPEN ";F$: REM WILL CREATE FILE IF IT DOES NOT EXIST.
|
|
140 PRINT D$;"READ ";F$
|
|
150 GET C$
|
|
160 PRINT C$;
|
|
165 IF C$ = CR$ THEN LINE = LINE + 1
|
|
167 IF LINE = 24 THEN INVERSE : PRINT PROMPT$;: NORMAL : PRINT D$: GOSUB
|
|
4000: GOSUB 3000: GOTO 140
|
|
170 GOTO 150: REM NEXT CHARACTER IN FILE
|
|
180 REM END OF MAIN, BUT UNREACHABLE BECAUSE OF CHARACTER LOOP
|
|
3000 REM ****************
|
|
3005 REM * *
|
|
3010 REM * ERASE PROMPT *
|
|
3015 REM * *
|
|
3020 REM ****************
|
|
3025 LET PL = LEN (PROMPT$)
|
|
3030 POKE 1403,0: REM BACKUP TO BEGINNING OF LINE
|
|
3060 PRINT SPC( PL): REM ERASE PROMPT
|
|
3070 POKE 1403,0: REM BACKUP AGAIN
|
|
3080 RETURN
|
|
4000 REM ***************
|
|
4005 REM * *
|
|
4010 REM * GET COMMAND *
|
|
4015 REM * *
|
|
4020 REM ***************
|
|
4030 GET CMD$
|
|
4040 IF CMD$ = CR$ THEN LINE = 23: GOTO 4060
|
|
4050 IF CMD$ = " " THEN LINE = 1: GOTO 4060
|
|
4055 IF CMD$ = "Q" OR CMD$ = "q" THEN PRINT D$;"CLOSE": PRINT D$: PRINT
|
|
: END
|
|
4060 RETURN
|
|
5000 REM *****************
|
|
5010 REM * *
|
|
5020 REM * ERROR HANDLER *
|
|
5030 REM * *
|
|
5040 REM *****************
|
|
5050 POKE 216,0: REM TURNS OFF 'ONERR GOTO' ERROR HANDLING
|
|
5060 LET ERRCODE = PEEK (222): REM GETS THE CODE FOR THIS ERROR
|
|
5070 PRINT D$;"CLOSE": REM CLOSES ANY OPEN FILES
|
|
5080 PRINT D$: REM TURNS OFF FILE I/O SO PRINTS GO TO SCREEN
|
|
5090 IF ERRCODE = 5 THEN 5290: REM END-OF-FILE IS NOT AN ERROR
|
|
5100 PRINT : PRINT : REM SEPARATES ERR MSG FROM ANY PREVIOUS OUTPUT
|
|
5120 REM CHECK FOR DOS/PRODOS ERRORS NOT IN APPLESOFT TABLE
|
|
5130 IF ERRCODE = 6 THEN PRINT "ERROR:FILE NOT FOUND:";F$
|
|
5140 IF ERRCODE = 11 THEN PRINT "ERROR:INVALID OPTION"
|
|
5150 IF ERRCODE = 255 THEN PRINT : PRINT : PRINT "INTERRUPTED BY CTRL-C"
|
|
5155 GOTO 5290: REM SKIP TO THE END
|
|
5160 REM COPY ERROR MESSAGE FROM APPLESOFT ERROR TABLE
|
|
5170 LET BASE = 53856: REM $D260, START OF APPLESOFT ERR TABLE
|
|
5180 LET PTR = BASE + ERRCODE: REM POINT TO 1ST BYTE OF ERR MSG
|
|
5185 PRINT "ERROR:";: REM PREFIX ALL PRINTED MESSAGES WITH THIS
|
|
5190 :
|
|
5195 REM LOOP TO PRINT CHARS OF ERR MSG FROM APPLESOFT ERROR TABLE
|
|
5200 REM WHILE (THERE ARE MORE CHARS IN MESSAGE) DO
|
|
5210 LET BYTE = PEEK (PTR): REM GETS BYTE POINTED TO BY PTR
|
|
5220 IF BYTE > = 128 THEN 5280: REM DETECTS LAST BYTE
|
|
5230 PRINT CHR$ (BYTE);: REM CNVTS ASCII BYTE TO CHAR, PRINT
|
|
5240 LET PTR = PTR + 1: REM ADVANCES POINTER TO NEXT BYTE
|
|
5250 GOTO 5210: REM LOOPS BACK TO NEXT BYTE
|
|
5260 REM END WHILE
|
|
5270 :
|
|
5280 PRINT CHR$ (BYTE - 128);: REM SETS HIGH BIT TO 0, PRINT
|
|
5290 END : REM THIS IS THE END - JIM MORRISON
|
|
|