通用文件压缩程序
10 CLS:CLOSE:C=0:M=0:N=0:PRINT"1-压缩 2-还原 0-返回":PRINT
20 T$=INKEY$:T=VAL(T$):IF T$=""THEN 20
30 ON T GOTO 40,220:GOTO 300
40 INPUT:"压缩原文件名:",RN$:PRINT:IF RN$="" THEN 10
50 INPUT:"压缩后文件名:",WN$:PRINT"IF WN$="" THEN 10
60 GOSUB 170:CLS:PRINT"压缩〈"RN$">文件成〈"WN$"〉文件":GOSUB 200
70 N=N+1:GOSUB 210:GET I,N:A=ASC(G$):IF A<>0 OR N>L THEN 100
80 GOSUB 290:M=M+1:IF M<257 THEN 70
90 B=255:GOSUB 160:B=1:GOSUB 160:B=0:GOSUB 160:M=0N=N-1:GOTO 70
100 B=M:GOSUB 160:GOSUB 290
110 M=0:N=N-1:C=C+1:D=C
120 N=N+1:GOSUB 210:GET 1,N:A=ASC(G$):IF A=0 THEN 150
130 GOSUB 290:C=C+1:LSETE$=G$:PUT2,C:M=M+1: IF M<255 THEN 120
140 C$=CHR$(255):LSETE$=C$:PUT2,D:B=0:GOSUB 160:N=N+1:GOTO 110
150 C$=CHR$(M):LSET E$=C$:PUT2,D,M+0:N=N-1:GOTO 70
160 C=C+1:C$=CHR$(B):LSET E$=C$:PUT2,C:RETURN
170 OPEN RN$ AS 1 LEN=1:FIELD 1,1 AS G$:L=LOF(1):IF L>0 THEN 190
180 PRINT:PRINT RN$"文件长=0,暂停运行!":CLOSE;KILL RN$:INPUT:"",T$:GOTO 10
190 OPEN WN$ AS 2 LEN=1:FIELD 2,1 AS E$:RETURN
200 PRINT:PRINT!"文件长="L:PRINTF:PRINT"已读到=":RETURN
210 LOCATE 5,9:PRINT N;:RETURN
220 INPUT;"还原原文件名:",RN$:PRINT: IF RN$="" THEN 10
230 INPUT;"还原后文件名:",WN$:PRINT:IF WN$="" THEN 10
240 GOSUB 170:CLS:PRINT"还原〈"RN$">文件成<"WN$"〉文件": GOSUB 200
250 N=N+1:GET I,N:A=ASC(G$):IF A=0 THEN 270
260 GOSUB 290:FOR I=1 TO A:M=M+1:GOSUB 210:LSET E$=CHR$(0):PUT2,M:NEXT
270 N=N+1:GET 1,N:A=ASC(G$):GOSUB 290:FOR I=1 TO A
280 M=M+1:N=N+1:GOSUB 210:GET1,N:LSET E$=G$:PUT2,M:NEXT:GOTO 250
290 IF N<=L THEN RETURN
300 PRINT"正常结束END":END(李仲辉)