CRUNCHER 26 May 2010 The BASIC CRUNCHER removes blanks an comments from Altair BASIC programs. This improves memory usage and speed, but reduces readability. Save the program in Ascii - SAVE "program name", A Keep a backup copy in readable format before crunching. Tom Sandersom www.virtualaltair.com 19 ' 20 CLEAR12000 30 ONERRORGOTO65000' 40 DEFINTA-Z' 50 PRINT" BASIC CRUNCHER." 60 GOSUB1000' 70 GOSUB2000' 80 GOSUB3000' 90 GOSUB4000' 95 ONERRORGOTO0' 100 PRINT" END OF CRUNCHING. " 999 END 1000 ' 1010 LC=0' 1020 PS=65' 1030 RS=60' 1040 PT=4' 1050 LF$=CHR$(10)' 1060 CH$="EOS"' 1070 OL$=""' 1080 CR$=CHR$(13)' 1090 QT$=CHR$(34)' 1100 KEY$="N"' 1999 RETURN 2000 ' 2010 INPUT" ENTER INPUT FILE NAME. ";IN$ 2015 INPUT" ENTER OUTPUT FILE NAME. ";OT$ 2020 AF$="Y" 2030 INPUT" IS THIS AN ASCII FILE? (ENTER N FOR NO OR RETURN FOR YES) ";AF$ 2038 IFAF$="NO"THENAF$="N" 2039 IFAF$="YES"THENAF$="Y" 2040 IFAF$="Y"THENGOTO2050ELSEIFAF$<>"N"THENGOTO2030 2045 PRINT" SAVE THE FILE USING THE 'A' OPTION AND TRY AGAIN. ":GOTO95 2050 ID=1' 2060 INPUT" ENTER DISK NUMBER (DEFAULT = 1) ";ID 2070 OPEN"I",#1,IN$,ID 2075 OPEN"O",#2,OT$,ID 2999 RETURN 3000 ' 3010 GOSUB8000' 3015 IFCH$="EOF"THENGOTO3999 3020 GOSUB22000' 3030 GOSUB10000' 3040 GOTO3010' 3999 RETURN 4000 ' 4010 CLOSE1' 4020 CLOSE2 4999 RETURN 8000 ' 8010 IFCH$="EOS"THENIFEOF(1)THENCH$="EOF":RETURNELSELINEINPUT#1,IR$:GOSU B11000 8020 IFSL=0THENCH$="EOS":RETURNELSECH$=LEFT$(IR$,1):SL=SL-1:IFSL>0THENIR $=RIGHT$(IR$,SL) 8999 RETURN 9000 ' 9001 GOSUB14000' 9003 RETURN 9004 ' 9005 ' 9006 IFCH$="'"THENGOSUB13000:RETURN' 9007 ' 9008 IFCH$=QT$THENGOSUB12000:RETURN' 9009 ' 9010 IF(CH$=LF$)OR(CH$=CR$)THENCH$="":RETURN 9999 RETURN 10000 ' 10010 IFCH$<>"EOS"THENOL$=OL$+CH$ELSEPRINT#2,OL$:LPRINTOL$:OL$="" 10999 RETURN 11000 ' 11001 OUT8,15 11002 SL=LEN(IR$) 11003 PRINTIR$ 11010 '' 11015 IFIR$=""THENRETURN 11020 LN$=LEFT$(IR$,INSTR(IR$," ")) 11030 LL=LEN(LN$) 11040 OL$=OL$+LN$ 11050 SL=SL-LL 11060 IR$=RIGHT$(IR$,SL) 11999 RETURN 12000 ' 12010 OL$=OL$+CH$' 12020 GOSUB8000' 12030 IFCH$="EOS"THENERROR(100):RETURN' 12040 IFCH$<>QT$THENGOTO12010 12999 RETURN 13000 ' 13001 OL$=OL$+"'" 13010 '' 13020 GOSUB8000' 13030 IFCH$<>"EOS"THENGOTO13010 13999 RETURN 14000 ' 14010 IFSL<2THENRETURN 14020 IF(CH$+LEFT$(IR$,2))="REM"THENOL$=OL$+"'":GOSUB13000' 14040 T4$=CH$+LEFT$(IR$,3) 14070 IFT4$<>"DATA"THENRETURN 14071 OL$=OL$+CH$:GOSUB8000:IFCH$<>"EOS"THENGOTO14071ELSERETURN 14999 RETURN 22000 ' 22010 IFCH$=" "THENGOSUB8000:GOTO22010' 22020 IF((CH$<"A")OR(CH$>"z")OR(CH$>"Z")AND(CH$<"a"))THENGOSUB9004ELSEGO SUB9000 22999 RETURN 65000 ' 65010 IFERR<>100THENGOTO65020 65011 PRINT" **** UNMATCHED QUOTES IN THE LINE BELOW. ";OL$;" " 65012 LPRINT" **** UNMATCHED QUOTES IN THE LINE BELOW. " 65013 RESUME12999 65020 IF(ERL<>11020)OR(ERR<>5)THENGOTO65030 65021 PRINT" **** LINE NUMBER NOT FOUND. ";IR$;" ":LPRINT" **** LINE NUMBER NOT FOUND. ";IR$ 65022 SL=0 65030 '' 65080 PRINT" **** ERROR NUMBER ";ERR;" IN LINE ";ERL 65090 RESUME90' 65099 RETURN OK