QB64 Phoenix Edition
Mac print #file crlf? - Printable Version

+- QB64 Phoenix Edition (https://qb64phoenix.com/forum)
+-- Forum: QB64 Rising (https://qb64phoenix.com/forum/forumdisplay.php?fid=1)
+--- Forum: Code and Stuff (https://qb64phoenix.com/forum/forumdisplay.php?fid=3)
+---- Forum: Help Me! (https://qb64phoenix.com/forum/forumdisplay.php?fid=10)
+---- Thread: Mac print #file crlf? (/showthread.php?tid=4474)



Mac print #file crlf? - BlameTroi - 02-15-2026

Two questions:

First, should I be entering an issue over on github for this sort of thing?

Second: Running on Mac I'm printing to a text file and the end of line is crlf but should be lf. I see that the doc says print will add a crlf. Is there any way to turn this off. I started looking at the C++ code and decided this was one I couldn't begin to tackle on my own Smile


RE: Mac print #file crlf? - ahenry3068 - 02-15-2026

Are you using PRINT #LFN,

   If so do this

           PRINT #LFN, "MYCONTENT";CHR$(10);

Terminating with a semi-colon will suppress the Automatic Line terminator then just insert the correct one
With CHR$(10)

even easier

CONST LF = CHR$(10)

                      PRINT #LFN, "MYCONTENT";LF;


RE: Mac print #file crlf? - SMcNeill - 02-15-2026

Even easier:

Code: (Select All)

SUB PrintOut (where as long, text$)
   PRINT #where, text$ + CHR$(10);
END SUB

Then just:

PrintOut #LFN, "Whatever you want"


RE: Mac print #file crlf? - ahenry3068 - 02-15-2026

(02-15-2026, 11:17 PM)SMcNeill Wrote: Even easier:

Code: (Select All)

SUB PrintOut (where as long, text$)
   PRINT #where, text$ + CHR$(10)
END SUB

Then just:

PrintOut #LFN, "Whatever you want"
This is in error Steve .    You still need the semi-colon after the CHR$(10) Then it will work properly.   
The way yours is written will end up   "CONTENT" 10,13,10  !!!!


Also by just using Print #LFN instead of this you can send any variable type.    Your's REQUIRES a string 
This isn't hard, I have a couple routines modeled similiarly, but it's still an extra step.


RE: Mac print #file crlf? - SMcNeill - 02-15-2026

Whatcha talking about?  Steve is Amazing!  He'd never leave out a semicolon or whatnot.  

And he'd never go back and edit a post to make it seem like he was right all along either!  Ignore that Edited by above... I have no idea where it came from.  Big Grin


RE: Mac print #file crlf? - BlameTroi - 02-16-2026

(02-15-2026, 11:11 PM)ahenry3068 Wrote: Are you using PRINT #LFN,

   If so do this

           PRINT #LFN, "MYCONTENT";CHR$(10);

Yes I am. For some reason when I started trying to figure this out yesterday I looked at Write but that loses some Print functionality.

Anyway, this gets the job done. Thanks to both you and Steve.

Additional background in case anyone else runs into this:

I only noticed the crlf because I was doing some diffs. MacVim and Terminal are both smart enough that the extra cr isn't really causing a problem beyond the diff. I don't run Linux but I assume similar issues would need similar solutions.