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

Re: Please help with BinSCII



Jeff Blakeney writes ...
> 
> On Fri, 23 Jun 2000 00:01:07 -0500, Rubywand <rubywand@swbell.net>
> wrote:
> 
> > The program reads through BINSCII.EXE and swaps in CR's for LF's. The
> > corrected Text is saved in RAM and used to create BINSCIIX.
> > EXEC BINSCIIX to get BINSCII.
> >
> > 100  ONERR  GOTO 170
> > 110  PRINT  CHR$ (4)"OPEN BINSCII.EXE"
> > 120  PRINT  CHR$ (4)"READ BINSCII.EXE"
> > 130  GET C$
> > 140  IF  ASC (C$) = 10 THEN C$ =  CHR$ (13)
> > 150 N = N + 1: POKE 8191 + N, ASC (C$): IF N / 100 =  INT (N / 100)
> >      THEN Z =  FRE (0): PRINT "*";
> > 160  GOTO 130
> > 170  PRINT : PRINT  CHR$ (4)"CLOSE"
> > 180  POKE 216,0
> > 190  PRINT  CHR$ (4)"OPEN BINSCIIX"
> > 200  PRINT  CHR$ (4)"WRITE BINSCIIX"
> > 210  FOR I = 1 TO N - 1: PRINT  CHR$ (PEEK (8191 + I));: NEXT I
> > 220  PRINT : PRINT  CHR$ (4)"CLOSE"
> > 230  END
> 
> Well, you forgot to clean up the stack again

     Nope; did not forget. You need to fuss with the stack cleanup CALL when
an ONERR triggers inside a subroutine. The above program uses no subroutines.


> but as you seem to have
> made this program overly complex, I'll post a version that will
> convert either LF or CR/LF end of lines to just CR.
> 
> 100 ONERR GOTO 210
> 110 D$ = CHR$(4)
> 120 PRINT D$;"OPEN BINSCII.EXE"
> 130 PRINT D$;"OPEN BINSCIIX"
> 140 PRINT D$;"READ BINSCII.EXE"
> 150 LC$ = C$:GET C$
> 160 IF ASC(C$) = 10 AND LC$ <> CHR$(13) THEN C$ = CHR$(13): GOTO 180
> 170 GOTO 150
> 180 PRINT D$;"WRITE BINSCIIX"
> 190 PRINT C$;
> 200 GOTO 140
> 210 POKE 216,0: CALL -3288
> 220 PRINT D$;"CLOSE"
> 230 END
>
 ....

     Trying to handle both LF and CR/LF makes a nice demo but slows down
execution for the intended application-- i.e. to just change LF's to CR's.

     Neither the POKE 216,0 (ONERR terminate) nor the CALL -3288 stack
cleanup are necessary here. The POKE 216,0 illustrates good practice; but,
the CALL -3288 is excessively pedantic in a short program with no subs.

     Getting rid of the RAM buffer is definitely worthwhile. On the other
hand, it looks like the code you use is going to produce a BINSCIIX file
filled with nothing but CR's.



Rubywand