#CR/LF only?
9 messages in this thread
Hi All!
I'm in the process of writing a program that generates AmigaGuide files..
now the problem that I'm having is that SAS/C (Lattice) always makes the
newline (\n) have both a control-m and a CR – making it a CR/LF which the
Amiga doesn't need, only the IBM does, and AmigaGuide refuses to read it
properly.
My program is generating the text correctly, as, when I remove the
control-m in CygnusEd it runs smoothly.
Is there anyway to make Lattice create only CRs and not the Control-Ms.
Hoping you can help!
Regards,
Andre Lackmann On AutoPilot and still outta control
A '\n' is a LF, which is a CTRL-J
A '\r' is a C/R, which is a Control-M
If you use only one of them in a printf(), it should only generate one
character, and it should be the right one. If it doesn't, the compiler is
broken, or perhaps has a software switch called out in the compile line.
If you are using something other than printf(), it could be part of the
problem. Could you tell us how you are generating the lines for the file? (just
one line as an example would help).
-larry
Hi Larry!
I'm using printf.. eg. printf("printing this line %s\n",string"); and i know
that the \r will generate a CR whicg [Dh takes me back to the new line without
deleting the present one…Hmm will look some more in the manual..
Lemme know if you think of anything!
Andre.
Well, that should generate just a LF. The only other thing I can think of is
that perhaps the string you are printing with the '%s' already has a CR in it.
-larry
>Well, that should generate just a LF. The only other thing I can think of
>is that perhaps the string you are printing with the '%s' already has a
>CR in it.
No it doesn't, that's what I thought too, but I checked in CygnusEd if the
file I was reading in had any, and it doesn't! So I guess I'm a little
stuck, unless I write a routine to go through this finished .Guide file
and strip the Control-Ms. Pity though, bit of a waste of time!
Regards,
Andre Lackmann On AutoPilot and still outta control
Interesting. I would call that compiler 'broken' if it generates a CTRL-M for a
'\n'.
-larry
Me, too. Glad this was resolved in my absence.
–Doug
Hi Andre,
Are you using the Lattice fopen function to open your file ? If so, you
should specify mode B translation which does not expand linefeeds to
linefeed+return.
You do this by making the second character of the mode parameter a b. For
example :
file = fopen ( "myfile", "wb" ) ; /* Open for write in mode b */
file = fopen ( "myfile", "wb+" ) ; /* Open for append in mode b */
Hope this is of help
Peter
Hi Peter!
>If so, you should specify mode B translation which does not expand
>linefeeds to linefeed+return.
>file = fopen ( "myfile", "wb" ) ; /* Open for write in mode b */
>file = fopen ( "myfile", "wb+" ) ; /* Open for append in mode b */
>Hope this is of help
Your absolutely right!! I am using 'wa' in the above example, not 'wb' as
you suggest..
Thanks you VERY VERY much, no I can get programming again!
Look out for my program, 'short2AG' – Converts AMINET Sites SHORT file
listing to AmigaGuide for ease of use.. Stupid I know, but I'm still
trying to teach myself 'C'!
Thanks again, your a saviour!
Regards,
Andre Lackmann On AutoPilot and still outta control