[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: rot13



In article <1995Feb7.204925.1@vaxc.stevens-tech.edu>,
 <khorster@vaxc.stevens-tech.edu> wrote:
> 	Is there a stand alone rot13 decoder for the Apple //?

I haven't heard of one, but it is a dead simple program.  You could
probably write one in BASIC in about twenty lines (reading a ROT-13
encoded file and outputting it to another file).

ROT-13 works by swapping each half of the alphabet (A-M move to N-Z
and vice versa, ditto for lower case).

Here is such a program.  It also does CR/LF or LF-only to CR
conversion.  The converted data is displayed on screen as the
conversion is performed, and the data is written to the output file in
small chunks.

10 D$=CHR$(4)
20 INPUT "Input File:";IF$: INPUT "Output File:";OF$
30 PRINT D$;"VERIFY ";IF$: PRINT D$;"OPEN ";IF$: PRINT D$;"OPEN ";OF$
40 ONERR GOTO 200: CR = 0
50 I = 0: B$ = "": PRINT D$;"READ ";IF$
60 GET A$
70 IF A$ = CHR$(13) THEN CR = 1: GOTO 130
80 IF A$ <> CHR$(10) THEN GOTO 110
90 A$ = CHR$(13): IF CR THEN CR = 0: GOTO 60
100 CR = 0: GOTO 130
110 IF (A$ >= "A" AND A$ <= "M") OR (A$ >= "a" AND A$ <= "m") THEN
    A$ = CHR$(ASC(A$) + 13): CR = 0: GOTO 130
120 IF (A$ >= "N" AND A$ <= "Z") OR (A$ >= "n" AND A$ <= "z") THEN
   A$ = CHR$(ASC(A$) - 13): CR = 0
130 B$ = B$ + A$: I = I + 1: PRINT A$;
140 IF I > 200 THEN PRINT D$;"WRITE ";OF$: PRINT B$;: GOTO 50
150 GOTO 60
200 POKE 216,0: ER = PEEK(222): EL = PEEK(218) + 256 * PEEK(219)
210 IF ER <> 5 THEN PRINT "ERROR #";ER;" ON LINE ";EL: GOTO 230
220 IF I THEN PRINT D$;"WRITE ";OF$: PRINT B$;
230 PRINT D$;"CLOSE"
240 END


If you want to modify this to only do the CR/LF and LF conversion,
delete line 120 and change line 110 to:

110 CR = 0

-- 
David Empson
dempson@actrix.gen.nz
Snail mail: P.O. Box 27-103, Wellington, New Zealand