10
20
30 :
40 A$=FN_OS_GetEnv:in%=0:out%=0:def$="DEFB":eol$=CHR$10
50 IF A$="":INPUT"Input file: "f1$:INPUT"Output file: "f2$:A$=f1$+" "+f2$
60 IF LEN A$<2:PRINT "Syntax: MkDEFB (<infile> <outfile>)":END
70 I%=INSTR(A$," "):f1$=LEFT$(A$,I%):f2$=MID$(A$,I%)
80 ON ERROR REPORT:PROCClose:PRINT ERL:END
90 in%=OPENIN(f1$):IF in%=0 PRINT"Can't open ";f1$:END
100 out%=OPENOUT(f2$):IF out%=0 PRINT"Can't save ";f2$:CLOSE#in%:in%=0:END
110 BPUT#out%,ASC"{":BPUT#out%,ASC" ":x%=0
120 REPEAT:PRINT;100*PTR#in%DIV EXT#in%;"%";CHR$13;
130 IF x%=0:PROCwr(out%,def$)
140 IF x%>0:PROCwr(out%,",")
150 PROCwr(out%,STR$BGET#in%)
160 x%=x%+1:IF x%>7:x%=0:PROCwr(out%,eol$)
170 UNTIL EOF#in%:PRINT:IF x%:PROCwr(out%,eol$)
180 CLOSE#out%:out%=0
190 CLOSE#in%:in%=0
200 END
210 :
220 DEFPROCwr(o%,A$):IF A$="":ENDPROC
230 REPEATBPUT#o%,ASCA$:A$=MID$(A$,2):UNTILA$="":ENDPROC
240 :
250 DEFPROCClose
260 IF out%:A%=out%:out%=0:CLOSE#A%
270 IF in%:A%=in%:in%=0:CLOSE#A%
280 ENDPROC
290 :
300 DEFFN_OS_GetEnv:IFHIMEM>&FFFF:IFPAGE<&FFFF:SYS"OS_GetEnv"TOA$:=MID$(A$,1+INSTR(A$," ",1+INSTR(A$," ",1+INSTR(A$," ")))) ELSE =""