[Implemented] PrintN() should produce #CRLF$

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
horst
Enthusiast
Enthusiast
Posts: 197
Joined: Wed May 28, 2003 6:57 am
Location: Munich
Contact:

[Implemented] PrintN() should produce #CRLF$

Post by horst »

Just found out that PrintN() appends a #LF$ only, which is ok for the console window output, but may cause problems when redirectied to a file.

Notepad.exe insists that lines must be terminated with CR+LF. Other editors are a little more flexible, and I don't use Notepad either, but that's why a user of my programs had to tell me about this.

Question: Why doesn't PB add #CRLF$ instead of #LF$, since on the screen there is no difference anyhow?
Horst.
User avatar
Rings
Moderator
Moderator
Posts: 1435
Joined: Sat Apr 26, 2003 1:11 am

Post by Rings »

ever think about being crossplattform ?
SPAMINATOR NR.1
horst
Enthusiast
Enthusiast
Posts: 197
Joined: Wed May 28, 2003 6:57 am
Location: Munich
Contact:

Post by horst »

Rings wrote:ever think about being crossplattform ?
Can you please exlain what that means for the problem I posted?
Horst.
traumatic
PureBasic Expert
PureBasic Expert
Posts: 1661
Joined: Sun Apr 27, 2003 4:41 pm
Location: Germany
Contact:

Post by traumatic »

horst wrote:
Rings wrote:ever think about being crossplattform ?
Can you please exlain what that means for the problem I posted?
Unix/Linux use LF only, Mac used to use CR only and DOS/Windows use CRLF - I guess that's what Rings meant to say
Good programmers don't comment their code. It was hard to write, should be hard to read.
User avatar
Demivec
Addict
Addict
Posts: 4260
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Post by Demivec »

horst wrote:Can you please exlain what that means for the problem I posted?
I think Rings means that CR+LF is a Windows only solution and wouldn't be considered crossplatform.
User avatar
djes
Addict
Addict
Posts: 1806
Joined: Sat Feb 19, 2005 2:46 pm
Location: Pas-de-Calais, France

Post by djes »

I think there should be an option to change this.
User avatar
tinman
PureBasic Expert
PureBasic Expert
Posts: 1102
Joined: Sat Apr 26, 2003 4:56 pm
Location: Level 5 of Robot Hell
Contact:

Post by tinman »

Demivec wrote:
horst wrote:Can you please exlain what that means for the problem I posted?
I think Rings means that CR+LF is a Windows only solution and wouldn't be considered crossplatform.
WriteStringN() creates CRLF on Windows, I guess it uses the correct line endings for the other platforms. I don't know why PrintN() should be different from that - use the line ending for the platform it is running on.
If you paint your butt blue and glue the hole shut you just themed your ass but lost the functionality.
(WinXPhSP3 PB5.20b14)
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Post by Psychophanta »

I would suppress PrintN() and WriteStringN() commands (if i was Fred).
Imo is at the hand of the programmer the eol character/s.
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

Demivec wrote:
horst wrote:Can you please exlain what that means for the problem I posted?
I think Rings means that CR+LF is a Windows only solution and wouldn't be considered crossplatform.
LF is a linux only solution and wouldn't be considered crossplatform either.
User avatar
Demivec
Addict
Addict
Posts: 4260
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Post by Demivec »

Psychophanta has a good point, being that you would just use Print(Text$+EOL$) instead of PrintN(Text$). That way you control what is written instead of the default.

I second what djes said also, there should be an option to change this.
horst
Enthusiast
Enthusiast
Posts: 197
Joined: Wed May 28, 2003 6:57 am
Location: Munich
Contact:

Post by horst »

@tinman:
> WriteStringN() creates CRLF on Windows, I guess it uses the correct line endings for the other platforms. I don't know why PrintN() should be different from that - use the line ending for the platform it is running on.

Thank you, that's the point.

@Psychophanta, Demivec:
I think it is not very realistic to ask for suppression of PrintN() and WriteStringN().
And as long as these commands exist, they should append the platform dependent EOL code.

@djes, Demivec:
I don't think, there should be an extra option (i.e. optional parameter). You can always code Print(text$ + #whatever$).
Horst.
freak
PureBasic Team
PureBasic Team
Posts: 5940
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post by freak »

I changed it to CRLF for windows.
quidquid Latine dictum sit altum videtur
User avatar
Rings
Moderator
Moderator
Posts: 1435
Joined: Sat Apr 26, 2003 1:11 am

Post by Rings »

...... i like such threads, i put a small sentence in it and it
solve itselfs


have you tried turn it off and on ???
Last edited by Rings on Tue Dec 04, 2007 1:52 pm, edited 1 time in total.
SPAMINATOR NR.1
Dare
Addict
Addict
Posts: 1965
Joined: Mon May 29, 2006 1:01 am
Location: Outback

Post by Dare »

:lol:
Dare2 cut down to size
naw
Enthusiast
Enthusiast
Posts: 573
Joined: Fri Apr 25, 2003 4:57 pm

Post by naw »

Trond wrote:
Demivec wrote:
horst wrote:Can you please exlain what that means for the problem I posted?
I think Rings means that CR+LF is a Windows only solution and wouldn't be considered crossplatform.
LF is a linux only solution and wouldn't be considered crossplatform either.
Actually <LF> is a Linux and Unix and BSD (which therefore presumably includes OSX) - so IMO <LF> is the standard and <CRLF> (Windows) or <CR> MacOS are the non-standard exceptions.

It seems to me that Windows uses <CR> & <LF> to end a line, so while that is inefficient it should be readable all major OS's (Unix & Linux & OSX & Win)
Ta - N
Post Reply