[comp.sys.apple] help for xmodem and text files

SEWALL@UCONNVM.BITNET.UUCP (06/03/88)

> What is the standard for xmodem and end of line for text files.
>Should xmodem translate cr <-> cr & lf for text files or what???????

XModem is even older than Apple; it originated in CP/M (somewhere
I've the phone number of the World's oldest BBS - Ward Christensen's
"Ward Board" in Chicago in continuous operation since February 1977
AND oddly enough, it's messages only with NO file transfer).  XModem
doesn't know the difference between text and binary file types, much
less Applesoft.  It's strictly an 8-bit transfer of whatever the file
contains.

Some of the problems:

While it'll transfer a binary file just dandy, it
transfers NONE of the directory entry info with it (assumes the receiver
will provide for that somehow); no start address, no length, no nothing.
Enter Apple II Binary (tah, tah).  If XModem is used to transfer an
BNY file it will be stored with an (arbitrary) start address of $0000
(BLOADing one crashes Apples!) and, often as not, the receiving end will
assign it a file type of TXT.  That bothers BLU (or any of the other
BNY unpackers) not a whit.  In the end BNY permits XModem to transfer
any kind of (ProDOS anyway) file.  Even C64 BBS's can archive BNY files.

XModem transfer of text files (which really is what your question speaks
to) is another kettle of fish altogether.  From Apple 2 to Apple 2 no
problem.  However, from Apple to another micro-system can cause beaucoup
problems.  DOS 3.3 text files are stored with the high bit set (negative
ASCII); the rest of the micro world chooses to have the high bit cleared.
Most (not all) other systems want CR/LF instead of just CR as a record
delimiter.  Mainframes, by and large, prefer only CR (which also is Apple's
preference), and I'm told Amigas want only LF.

Apple DOS 3.3 to MS-DOS usually confuses the bbs software to the extent that
the file is stored in "Intel8088 binary" (or some such, I may have
misremembered the exact nomenclature).  MS-DOS wants the 8th bit cleared and
CR/LF.

There is at least one ProDOS utility that will add or strip LF after CR
(text files received by XModem from MS-DOS systems ALWAYS have CR/LF).
One of the nice features of SOFTERM is that it provides a "menu" of options
when XMODEM is envoked (a partial rendition of which is) -

Add LF after CR  N        Delete LF after CR  N
Change LF to CR  N        Change CR to LF     N
Set high bit     N        Clear high bit      N
File type        B
Start address    A$0000  <ignored for 'T' file and $0803 for 'A' file>

---------------------
Disclaimer: The "look and feel" of this message is exclusively MINE!
            (subject to change without notice; void where prohibited)

ARPA:   sewall%uconnvm.bitnet@mitvma.mit.edu       Murphy A. Sewall
BITNET: SEWALL@UCONNVM                          School of Business Admin.
UUCP:   ...ihnp4!psuvax1!UCONNVM.BITNET!SEWALL  University of Connecticut

kamath@reed.UUCP (Sean Kamath) (06/08/88)

In article <3148@charon.unm.edu> cscbrkac@unmc.UUCP (Lazlo Nibble) writes:
>If you're
>having trouble with Apple <--> Unix textfile transfers, the following aliases I
>use might come in handy:
>
>alias nl2cr     "cat \!^ | tr '\012' '\015' > \!^.X ; rm -f \!^ ; mv \!^.X \!^"
>alias cr2nl     "cat \!^ | tr '\015' '\012' > \!^.X ; rm -f \!^ ; mv \!^.X \!^"
  [Actually, tr takes stding and send to stdout.  
	tr ... <in >out; mv -f out in
  does the smame thing]
>Before you download a Unix file to your Apple, type "nl2cr <file>" and after
>you upload an Apple file to the Unix system type "cr2nl <file>".  Takes care
>of the incompatibilities between the Apple and Unix line delimiters.
>
>-- 
>Lazlo Nibble (cscbrkac@charon.unm.edu)

Perhaps a little bit better method is to make a shell script to do that
*and* download the file.  Similarly for uploads.  I ended up with fours
files (which I guess would very easily be sent into one with a flag), two
for uploads, two for downs (One is DOS 3.3, the other ProDOS.).

ex:

#!/bin/sh
mkdir /tmp/tmp.$$
for i in $*
do
tr '\012' '\015' < $i > /tmp/tmp.$$/$i.up
done
#either x or y modem works here
ymodem -flags `/bin/ls /tmp/tmp.$$`
rm -f /tmp/tmp.$$
exit 0

Of course, more is needed if you want to do a series of xmodems.

The point is, that in mangling files, it's much better to make the
modifications somewhere else, to *something* else.  This way, the 
modificatons don't muck around with the originals, and you don't have to
remember to do them separately.

Sean Kamath
(Sorry for all you VMS-types. . .Though I'm sure you could so something
similar.)

-- 
UUCP:  {decvax allegra ucbcad ucbvax hplabs ihnp4}!tektronix!reed!kamath
CSNET: reed!kamath@Tektronix.CSNET  ||  BITNET: reed!kamath@PSUVAX1.BITNET
ARPA:  reed!kamath@PSUVAX1.CS.PSU.EDU
US Snail: 3934 SE Boise, Portland, OR  97202-3126 (I hate 4 line .sigs!)