🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.sources.atari.st
1 messages
1 total messages Started by atari-sources-request Mon, 09 Nov 1987 10:17
v00i035: bas:all: UUCODE.BAS - basic version of uudecode
#326
Author: atari-sources-request
Date: Mon, 09 Nov 1987 10:17
111 lines
4864 bytes
Submitted by: imagen!ucbvax!decvax!sbcs!lean (Lean L. Loh)
comp.sources.atari.st: Volume 0, Issue 35
Archive-name: uucode.bas

=++=++=++=++=++=++=++=++=++=++=++=++=++=++=++=++=++=++=++=++=++=++=++=++=++=++=
[Editor's Note]
	My basic disk is trashed (shows you how much i use it) so i will
have to believe the submitter that this works. This is a 'bootsrap' version
of uudecode that you can you use to decode the next posting of the real
uuen/decode binaries, arc will follow soon after
=++=++=++=++=++=++=++=++=++=++=++=++=++=++=++=++=++=++=++=++=++=++=++=++=++=++=


Hello,   Here's the BASIC version of UUDECODE that I pulled off the net
ages ago, which served as my 'bootstrap'.

============================================================


10    ' UUDECODE PROGRAM
11    ' /*
12    '  * Uudecode -- decode a uuencoded file back to binary form
13    '  *
14    '  * Slightly modified from a version posted to net.sources once;
15    '  * suitable for compilation on an IBM PC.
16    '  *
17    '  * modified for Lattice C on the ST - 11.05.86 by MSD
18    '  *
19    '  * rewritten for ST BASIC on the Atari ST - September 9, 1986,
20    '  *   by Patrick Simon
21    '  *
22    '  */

23    ' Initializations.
24    DIM I(4)
25    FULLW 2 : CLEARW 2 ' Use full output window, clear it.
26    MASK = 63 : SP = ASC(" ")

30    ' Get input filename and open file.
40    INPUT "Enter name of uuencoded file > ", IFILEN$
50    OPEN "I", #1, IFILEN$

60    ' Get output filename, open, and set up pointers.
70    INPUT "Enter name of output file > ", OFILEN$
80    OPEN "R", #2, OFILEN$, 45
90    FIELD #2, 45 AS CBUF$

110   ' Input and ignore first line of input file (original filename).
120   LINE INPUT #1, INLINE$ ' Due to a bug in ST BASIC, LINE INPUT #
130   LINE INPUT #1, INLINE$ '  must be called 2x, just to get first
140                          '  line. Even then we lose the 1st character.

150   ' Now set up screen for user.
160   CLEARW 2
170   GOTOXY 1,2 : PRINT "Decoding "; IFILEN$; " to "; OFILEN$
180   GOTOXY 1,4 : PRINT "# lines read in: "
190   GOTOXY 1,5 : PRINT "# bytes output: "

200   ' Initialize some variables for main body of program.
210   NUML = 0 : BYTEOUT = 0

220   LINELOOP: ' Now loop for as long as there are input lines.
230      LINE INPUT #1, INLINE$           ' LINE INPUT should work OK by now!
231      IF INLINE$ = "end" THEN GOTO 500 ' All done
232      NUML = NUML + 1

240   ' For each line, must "decode" each byte.
241   ' First byte contains # bytes to ***output*** from this line.
242   ' Then, after decoding, each set of 4 input bytes contains 6*4 = 24
243   '  bits of information to output, 8 bits per output byte, thus
244   '  3 output bytes.

250   ' Set up string position pointer for INLINE$
260      SPTR = 1

270   ' Get first byte = # bytes to output; exit if line has zero to output
280      GOSUB DECODE : NN = C : N = NN : IF NN = 0 THEN GOTO 500

285   ' Process one line of input
290      MPTR = 1
300      WHILE N > 0          ' Decode set of 4 input bytes.
310         FOR J = 1 TO 4
320            GOSUB DECODE : I(J) = C
330         NEXT J
340         C1 = ((I(1) *  4) MOD 256) + INT(I(2) / 16)
350         C2 = ((I(2) * 16) MOD 256) + INT(I(3) /  4)
360         C3 = ((I(3) * 64) MOD 256) + I(4)
370         IF N>0 THEN MID$(CBUF$,MPTR,1)=CHR$(C1) : MPTR = MPTR + 1
380         IF N>1 THEN MID$(CBUF$,MPTR,1)=CHR$(C2) : MPTR = MPTR + 1
390         IF N>2 THEN MID$(CBUF$,MPTR,1)=CHR$(C3) : MPTR = MPTR + 1
400         N = N - 3
410      WEND                 ' If more in this line, go back again.

415   ' Finished processing line.
420      PUT #2, NUML               ' Send decoded stuff to output file.
430      BYTEOUT = BYTEOUT + NN     ' Show status to user.
440      GOTOXY 20,4 : PRINT NUML
445      GOTOXY 20,5 : PRINT BYTEOUT
450   GOTO LINELOOP                 ' Get next line ...

500   ' Hopefully, we have now decoded the input file.
510   CLOSE #1 : CLOSE #2
520   END

1000  DECODE: ' Subroutine to decode a single character
1010     IF LEN(MID$(INLINE$,SPTR)) = 0 THEN INLINE$ = INLINE$ + " "
1020     CH$ = MID$(INLINE$, SPTR, 1) : SPTR = SPTR + 1
1030     C = (ASC(CH$) - SP) AND MASK
1040  RETURN

==========================================
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads