10
20
30 :
40 A$=FN_OS_GetEnv:in%=0:out%=0
50 IF A$="":INPUT"Input file: "f1$:INPUT"Output file: "f2$:A$=f1$+" "+f2$
60 IF LEN A$<2:ERROR 220,"Syntax: MkCData (<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 byte%=BGET#in%
140 BPUT#out%,ASC"0":BPUT#out%,ASC"x"
150 BPUT#out%,ASC STR$~(byte%DIV16)
160 BPUT#out%,ASC STR$~(byte%AND15)
170 BPUT#out%,ASC",":BPUT#out%,ASC" "
180 x%=x%+1:IF x%>7 x%=0:BPUT#out%,10:BPUT#out%,ASC" ":BPUT#out%,ASC" "
190 UNTIL EOF#in%:PRINT
200 BPUT#out%,ASC"}"
210 CLOSE#out%:out%=0
220 CLOSE#in%:in%=0
230 END
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 =""