[comp.sys.apple2] Stripping LF's from files

v060q267@ubvmsb.cc.buffalo.edu (David B Bandish) (11/27/90)

I download text file from the VAX at UB.  However, the Vax uses LF's to
separate lines from each other and automatically inserts the CR when reading.

When a file is downloaded, it has LF's where the CR's should be.  Does anybody
know of a program that is either free or cheap that will replace the LF's with
CR's?  Currently I am using a program called SOFTTERM to do this, but SOFTTERM
barely deals with Prodos, and it is a messy proceedure at best.  I would like
something in Prodos that I can put on my HD.

Thank you for your assistance

Dave

MQUINN%UTCVM@PUCC.PRINCETON.EDU (11/28/90)

On Mon, 26 Nov 90 23:11:21 GMT <info-apple-request@APPLE.COM> said:
>I download text file from the VAX at UB.  However, the Vax uses LF's to
>separate lines from each other and automatically inserts the CR when reading.
>
>When a file is downloaded, it has LF's where the CR's should be.  Does anybody
>know of a program that is either free or cheap that will replace the LF's with
>CR's?  Currently I am using a program called SOFTTERM to do this, but SOFTTERM
>barely deals with Prodos, and it is a messy proceedure at best.  I would like
>something in Prodos that I can put on my HD.
>
>Thank you for your assistance
>
>Dave

I -THINK- that the linefeeds are ASCII code 10 (decimal).  If this is the
case, here's a short program that'll do it:

5 ONERR GOTO 120
10 D$=CHR$(4)
20 SR$="SOURCE.FILE"
30 DT$="DEST.FILE"
40 ?D$;"OPEN ";SR$
50 ?D$;"OPEN ";DT$
60 ?D$;"READ ";SR$
70 GET A$
80 IF ASC(A$)= 10 THEN A$=CHR$(13)
90 ?D$;"WRITE ";DT$
100 ?A$;
110 GOTO 60
120 ?D$;"CLOSE ";SR$
130 ?D$;"CLOSE ";DT$


This -SHOULD- strip the LF's and replace them with CR's.  I have to do
this with several files I download from my CMS account, but they're a little
different; they have BOTH LF's and CR's, so I just strip the linefeeds off
like this:

Using previous program, delete lines 70 and 80 and insert a new line 70:

70 INPUT A$

And leave the rest the same.

Hope this helps.

----------------------------------------
  Michael J. Quinn
  University of Tennessee at Chattanooga
  BITNET--   mquinn@utcvm
  pro-line-- mquinn@pro-gsplus.cts.com

bchurch@oucsace.cs.OHIOU.EDU (Bob Church) (11/28/90)

In article <47643@eerie.acsu.Buffalo.EDU>, v060q267@ubvmsb.cc.buffalo.edu (David B Bandish) writes:
> 
> When a file is downloaded, it has LF's where the CR's should be.  

Why not use tr or sed to replace the Line Feeds with Carriage Returns before
downloading?

bob church
bchurch.oucsace.cs.ohiou.edu

reeder@reed.bitnet (Doug Reeder,,,2343817) (12/09/90)

Under unix, define the following:

alias lf2cr "cat \!^ | tr '\012' '\015' > \!^.X ; rm -f \!^; mv \!^.X \!^"
alias cr2lf "cat \!^ | tr '\015' '\012' > \!^.X ; rm -f \!^; mv \!^.X \!^"

You can put these lines in your .cshrc file on your unix account, so they'll
always be there.

Usage:

lf2cr unixfile

afterwards, unixfile will contain an apple format text file.

gammal@CAM.ORG (Michael Gammal) (12/11/90)

MQUINN%UTCVM@PUCC.PRINCETON.EDU writes:

>On Mon, 26 Nov 90 23:11:21 GMT <info-apple-request@APPLE.COM> said:
>>I download text file from the VAX at UB.  However, the Vax uses LF's to
>>separate lines from each other and automatically inserts the CR when reading.
>>
>>When a file is downloaded, it has LF's where the CR's should be.  Does anybody
>>know of a program that is either free or cheap that will replace the LF's with
>>CR's?  Currently I am using a program called SOFTTERM to do this, but SOFTTERM
>>barely deals with Prodos, and it is a messy proceedure at best.  I would like
>>something in Prodos that I can put on my HD.
>>
>>Thank you for your assistance
>>
>>Dave
>  University of Tennessee at Chattanooga
>  BITNET--   mquinn@utcvm
>  pro-line-- mquinn@pro-gsplus.cts.com

There is a program called Change File, shareware I believe, that will do just
what you want and has some appleworks features as well.

More Power To You!

-- 
Michael Gammal		Concordia University		M.Gammal@CAM.ORG

AABENSON@MTUS5.BITNET (12/12/90)

Michael was asking about a line-feed stripper... I have one that I wrote, but
it's not on my Apple.  I use it on the Unix side BEFORE I transfer it to my
computer.  It's actually quite a short Pascal program.  If anybody would
like it, then email me at my Internet address.

                                              - Andrew.
Internet: aabenson@balance.cs.mtu.edu
Bitnet: AABENSON@MTUS5.BITNET

P.S.  I suppose you could use it on the Apple if you happen to have a
Pascal compiler sitting around.  Everything it does is very standard --
it doesn't break any rules (that I know of).