5  'Run this program on the micro in conjunction with a Fortran program on the
6  ' mainframe to get Kermit to the micro
7  ' Daphne Tzoar , December 1983
8  ' Columbia University Center for Computing Activities
9  ' Sirius version, Barry Devlin, University College Dublin, April 1984
10 DEF SEG =&HE004
20 DIM L(100)
40 OPEN "O",2,"KERMIT.EXE"
50 OK$ = "ok"+CHR$(13)
60 GOSUB 500      'Get a line
80 VALUE$ = LEFT$(X$,1)      'First char of input
90 VALUE = ASC(VALUE$)
100 IF VALUE = 64  GOTO 430   ' @ means we're done
110 'Kill all illegal chars
120 IF VALUE >= 48 AND VALUE <= 63 THEN GOTO 140
130 X$ = MID$(X$,2) : GOTO 80
140 IF VALUE <> 46 GOTO 210     ' Not a dot (for read) - don't worry
150 TWO$ = MID$(X$,2,1)          ' Look at char after the dot.
160 TWO = ASC(TWO$)
170 IF TWO >= 176 AND TWO <= 191 THEN GOTO 210    ' It's ok.
180 IF TWO >= 48 AND TWO <= 63 THEN GOTO 210
190 X$ = MID$(X$,3)	    ' Kill the char
200 GOTO 80
210 SIZ = LEN(X$)           ' How much input was actual data
220 READIN = 64 - SIZ
225 IF READIN = 0 GOTO 260
230 'XTWO$=INPUT$(READIN,#1)     ' Get rest of data
240 'X$ = X$ + XTWO$ : X$ = LEFT$(X$,62)
260 GOSUB 290
270 PRINT#2,X$;      ' Put data to the file.
280 GOTO 60
290 ' GET TWO CHARS, SUBTRACT SPACE (20 HEX) FROM EACH, AND COMBINE
300 ' TO ONE DIGIT.
310 FOR A = 1 TO 31
320 Y$ = MID$(X$,A,1)
330 Z$ = MID$(X$,A+1,1)
340 YNUM = ASC(Y$) : ZNUM = ASC(Z$)
370 YNUM = YNUM -48 : ZNUM = ZNUM -48       ' Subtract the space
380 XNUM = (16 * YNUM) +ZNUM
390 NEWCHR$ = CHR$(XNUM)
400 X$ = MID$(X$,1,A-1) + NEWCHR$ + MID$(X$,A+2)
410 NEXT A
420 RETURN
430 PRINT  " [All done.]"
440 CLOSE #2                            ' Clean up.
450 END
500 X$=""
501 POKE 0,ASC("O")
502 FOR I = 2 TO 3
505 B=PEEK(2) AND 4
510 IF B = 0 THEN 505
520 POKE 0,ASC(MID$(OK$,I,1))
523 NEXT I
525 B=PEEK(2) AND 1
526 IF B=0 THEN 525
527 B=PEEK(0) AND 127
528 IF B = 40 THEN 530
529 GOTO 525
530 I=0
535 B = PEEK(2) AND 1
540 IF B = 0 THEN 535
542 I=I+1
545 L(I)=PEEK(0) AND 127
550 IF L(I)=10 THEN 565
560 GOTO 535
565 FOR I= 1 TO 62 : X$=X$+CHR$(L(I)) : NEXT I : PRINT X$
570 RETURN
