SET NO DOUBLE 
10 REM LOADER program for PRO/Kermit for printer port
20 HEX$="123456789ABCDEF"
30 OAD=0\FLAG%=0\TOT%=0
40 TOT1%=0\CTR%=0\NM%=-1
100 OPEN "LP:" FOR INPUT AS FILE #2%
110 OPEN "LP:" FOR OUTPUT AS FILE #3%
170 GOTO 200
180 INPUT #2%,A$\ GOTO 210
190 PRINT "N";\ PRINT #3,"N"\ INPUT #2%,A$\ GOTO 210
200 PRINT #3,"Y"\ INPUT #2%,A$
210 IF A$="" THEN FLAG%=FLAG%+1%\ IF FLAG%>4% THEN 1100 ELSE 180
220 FLAG%=0
230 IF MID$(A$,1%,1%)<>":" THEN A$=MID$(A$,2%,LEN(A$))\ GOTO 210
240 H$=MID$(A$,2%,2%)\ GOSUB 1200\LN%=H\ REM LENGTH (NUMBER OF WORDS OF DATA)
250 REM FIND CHECKSUM OF ALL 8-BIT PAIRS
260 CHKSUM%=LN%
270 FOR L1%=4% TO (LN%+5%)*2% STEP 2%\H$=MID$(A$,L1%,2%)\ GOSUB 1200
280 CHKSUM%=CHKSUM%+H
290 NEXT L1%
300 CHKSUM%=CHKSUM%-256%*INT(CHKSUM%/256)
310 IF CHKSUM%<>0% THEN 190
320 IF MID$(A$,2%,6%)="000000" THEN 1100
330 H$=MID$(A$,8%,2%)\ IF H$<>"FC" THEN 380
340 H$=MID$(A$,10%,4%)\ GOSUB 1200\TOT1%=H*256%
350 DIM #1%,ARR%(TOT1%)
360 OPEN "LOAD.TSK" FOR OUTPUT AS FILE #1%, VIRTUAL 
370 GOTO 490
380 GOSUB 1200\ IF H<>0 THEN 200\ REM CHECK FIELD TYPE
390 IF TOT1%=0 THEN PRINT "No length field, can not create file"\ GOTO 1300
400 H$=MID$(A$,4%,4%)\ GOSUB 1200\OAD1=H\ REM ADDRESS TO LOAD AT
410 REM UNPACK ANY COMPRESSED NULLS
420 L%=0%\ FOR LP=OAD TO OAD1-1\ GOSUB 1000\ NEXT LP
430 OAD=OAD1
440 REM GET DATA AS 8-BIT VALUES AND WRITE TO DISK (REPEAT LN% TIMES)
450 FOR L1%=10% TO LN%*2%+9% STEP 2%
460 H$=MID$(A$,L1%,2%)\ GOSUB 1200\L%=H\ GOSUB 1000
470 OAD=OAD+1
480 NEXT L1%
490 PRINT CHR$(CTR%+65%);\CTR%=CTR%+1%\ IF CTR%>24% THEN CTR%=0%\ PRINT 
500 GOTO 200
510 STOP 
990 REM WRITE - PUT THE DATA INTO THE TASK FILE
1000 IF NM%=-1 THEN NM%=L%\ RETURN 
1010 N=NM%+L%*256
1020 IF N>32767 THEN N=N-65536
1030 NB%=N
1040 ARR%(TOT%)=NB%
1050 NM%=-1\TOT%=TOT%+1%
1060 RETURN 
1090 REM FINISHED - CLOSE FILE
1100 PRINT \ PRINT \ PRINT "TASK FILE WRITTEN."
1110 CLOSE 
1120 GOTO 1300
1190 REM HEX-DEC
1200 H=0
1210 FOR LP%=1% TO LEN(H$)
1220 H=H*16+POS(HEX$,MID$(H$,LP%,1%),1%)
1230 NEXT LP%
1240 RETURN 
1300 END 
