[comp.sys.atari.st] GFA basic version of uudecode

logajan@ns.UUCP (John Logajan x3118) (08/18/88)

This is a working but unfinished uudecode program in GFA Basic.
I used it successful on a total of one out of one attempts.

It does not (yet) handle line lengths other than "M" (45 undecoded chars.)

uuencode format:

The first character indicates the number of bytes encoded into the
current line.  (M=45  typical)

Thereafter three 8-bit bytes are split into four 6-bit characters.
So you have to unpack groups of four characters into three bytes.

There are two end cases left to handle:
  1.) Line lengths other than 45 but ending with a three byte group.
  2.) Line lengths other that 45 ending with less than a three byte group.
Good luck.

Dim C(45),L(61)
Input "Name of file to decode";F$
Open "I",#1,F$
Repeat
  Line Input #1,B$
Until Left$(B$,5)="begin"
O$=Mid$(B$,11,12)
Print O$
Open "O",#2,O$
While Left$(B$,3)<>"end"
  Exit If Eof(#1)
  Line Input #1,B$
  For J=1 To 61
    L(J-1)=(Asc(Mid$(B$,J,1))-32) And 63
  Next J
  K=1
  For J=1 To 45 Step 3
    C(J)=L(K)*4+Int(L(K+1)/16)
    C(J+1)=(L(K+1)*16+Int(L(K+2)/4)) And 255
    C(J+2)=(L(K+2)*64+L(K+3)) And 255
    K=K+4
    Print #2,Chr$(C(J));Chr$(C(J+1));Chr$(C(J+2));
  Next J
Wend
End
-- 
- John M. Logajan @ Network Systems; 7600 Boone Ave; Brooklyn Park, MN 55428 -
- {...rutgers!dayton, ...amdahl!ems, ...uunet!rosevax!mmm} !viper!ns!logajan -