|
Post by kendown on Mar 25, 2020 21:44:48 GMT
insert code here REM The program allows you to view and alter the contents of a file byte by byte. REM <Shift>+<Ctrl>+"@" for 0, Return to exit REM Arrow keys to move one byte at a time, PageUp and Down to move one screen at a time REM Ctrl+PageUp and Down to move &1000, Shift+Ctrl+PageUp and Down to move &10000 REM Please only work on a copy of your file, as changes are immediate and cannot be undone.
ON CLOSE CLOSE#F%:END
filename$="F:\\Books\Story.txt"
F%=OPENUPfilename$ ptr%=0 ext%=EXT#F% PRINTTAB(82,0)FNpad(ext%,6) PROCdisplay(ptr%) COLOUR4 PRINTTAB(12,34)"<Menu> or <Adjust> to exit" PRINTTAB(10,35)"<Return> to select editing mode" COLOUR0 REPEAT PROCget UNTILmb%<4 CLOSE#F% SOUND1,-9,100,2 END : DEFPROCget REPEAT REPEAT:MOUSEmx%,my%,mb%:UNTILmb%>0 REPEAT:MOUSEx%,y%,b%:UNTILb%=0 IFmx%<916ANDmx%>112THEN tx%=(mx%-112)DIV48 IFmy%>450ANDmy%<1432THEN ty%=(my%-458)DIV30 GCOL3,1:RECTANGLEFILL128+tx%*48,ty%*30+448,32,30 ascii%=FALSE ENDIF ENDIF IFmx%>932ANDmx%<1180THEN tx%=(mx%-932)DIV16 IFmy%>450ANDmy%<1432THEN ty%=(my%-458)DIV30 GCOL3,1:RECTANGLEFILL928+tx%*16,ty%*30+448,16,30 ascii%=TRUE ENDIF ENDIF UNTILmb%>0 IFmb%=4THEN IFascii%PROCascii ELSEPROChex ENDIF ENDPROC : DEFPROChex LOCALc%,c$ c$="" REPEAT g%=GET GCOL3,1:RECTANGLEFILL128+tx%*48,ty%*30+448,32,30 CASEg%OF WHEN13 WHEN48,49,50,51,52,53,54,55,56,57,65,66,67,68,69,70 c$+=CHR$g% g%=EVAL("&"+c$) PRINTTAB(8+tx%*3,32-ty%)FNpad(g%,2) IFLENc$=2THEN pt%=(32-ty%)*16+tx%+ptr% PTR#F%=pt% BPUT#F%,g% PRINTTAB(8+tx%*3,32-ty%)FNpad(g%,2) IFg%<32ORg%>127g%=46 PRINTTAB(58+tx%,32-ty%)CHR$g% tx%+=1:IFtx%>15tx%=0:ty%-=1 c$="" ENDIF WHEN132:IFptr%>&200ptr%-=&200:PROCdisplay(ptr%) WHEN133:IFptr%<ext%-&200ptr%+=&200:PROCdisplay(ptr%) WHEN136:IFtx%>0tx%-=1ELSEty%+=1:tx%=15:IFty%>32tx%=0:ty%=32 WHEN137:IFtx%<15tx%+=1ELSEty%-=1:tx%=0:IFty%<0ty%=0:ptr%+=16:PROCdisplay(ptr%) WHEN138:IFty%>0ty%-=1ELSEptr%+=16:PROCdisplay(ptr%) WHEN139:IFty%<32ty%+=1ELSEIFptr%>15ptr%-=16:PROCdisplay(ptr%) WHEN158 IFINKEY-1=-1THEN IFptr%>&10000ptr%-=&10000:PROCdisplay(ptr%) ELSE IFptr%>&1000ptr%-=&1000:PROCdisplay(ptr%) ENDIF WHEN159 IFINKEY-1=-1THEN IFptr%<ext%-&10000ptr%+=&10000:PROCdisplay(ptr%) ELSE IFptr%<ext%-&1000ptr%+=&1000:PROCdisplay(ptr%) ENDIF ENDCASE GCOL3,1:RECTANGLEFILL128+tx%*48,ty%*30+448,32,30 PRINTTAB(82,1)FNpad((32-ty%)*16+tx%+ptr%,6) UNTILg%=13 GCOL3,1:RECTANGLEFILL128+tx%*48,ty%*30+448,32,30 ENDPROC : DEFPROCascii pt%=0 REPEAT g%=GET GCOL3,1:RECTANGLEFILL928+tx%*16,ty%*30+448,16,30 CASEg%OF WHEN13 WHEN132:IFptr%>&200ptr%-=&200:PROCdisplay(ptr%) WHEN133:IFptr%<ext%-&200ptr%+=&200:PROCdisplay(ptr%) WHEN136:IFtx%>0tx%-=1ELSEty%+=1:tx%=15:IFty%>32tx%=0:ty%=32 WHEN137:IFtx%<15tx%+=1ELSEty%-=1:tx%=0:IFty%<0ty%=0:ptr%+=16:PROCdisplay(ptr%) WHEN138:IFty%>0ty%-=1ELSEptr%+=16:PROCdisplay(ptr%) WHEN139:IFty%<32ty%+=1ELSEIFptr%>15ptr%-=16:PROCdisplay(ptr%) WHEN158 IFINKEY-1=-1THEN IFptr%>&10000ptr%-=&10000:PROCdisplay(ptr%) ELSE IFptr%>&1000ptr%-=&1000:PROCdisplay(ptr%) ENDIF WHEN159 IFINKEY-1=-1THEN IFptr%<ext%-&10000ptr%+=&10000:PROCdisplay(ptr%) ELSE IFptr%<ext%-&1000ptr%+=&1000:PROCdisplay(ptr%) ENDIF OTHERWISE pt%=(32-ty%)*16+tx%+ptr% PTR#F%=pt% BPUT#F%,g% PRINTTAB(8+tx%*3,32-ty%)FNpad(g%,2) IFg%<32ORg%>127g%=46 PRINTTAB(58+tx%,32-ty%)CHR$g% tx%+=1:IFtx%>15tx%=0:ty%-=1 ENDCASE GCOL3,1:RECTANGLEFILL928+tx%*16,ty%*30+448,16,30 PRINTTAB(82,0)FNpad(ext%,6) PRINTTAB(82,1)FNpad((32-ty%)*16+tx%+ptr%,6) UNTILg%=13 GCOL3,1:RECTANGLEFILL928+tx%*16,ty%*30+448,16,30 ENDPROC : DEFPROCdisplay(pt%) LOCALc%,c$ PTR#F%=pt% FORi%=0TO32 ptr$=FNpad(pt%,6) PRINTTAB(0,i%)ptr$ FORj%=0TO15 c%=BGET#F% PRINTTAB(8+j%*3,i%)FNpad(c%,2) IFc%>31ANDc%<127c$=CHR$c%ELSEc$="." PRINTTAB(58+j%,i%)c$ NEXT pt%=PTR#F% NEXT ENDPROC : DEFFNpad(n%,l%) =RIGHT$("000000"+STR$~n%,l%)
|
|