Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2004-09

const sLineBreak

17 messages · 6 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Darek Mazur

HI

I need that WRITELN make the same end of line in Linux and Win32,

I found sLineBreak, but for some OS it is var, for some const,

There is second identifier LineEnding (mostly const)

I think, tha one should be const, and second var, and when somebody need changes behavour of WRITELN that he can do it.

Darek

Reply by email

Michael Van Canneyt
to Darek Mazur
Darek Mazur wrote 10 lines
HI I need that WRITELN make the same end of line in Linux and Win32, I found sLineBreak, but for some OS it is var, for some const, There is second identifier LineEnding (mostly const) I think, tha one should be const, and second var, and when somebody need changes behavour of WRITELN that he can do it.

The purpose of this constant is not to be able to set the lineending, it gives the lineending which is the default on the current platform.

If you need to have the same lineending on all platforms, you must do your writes yourself. I would suggest using TStreams then.

Michael.

Reply by email

Darek M
to Michael Van Canneyt
Show quoted text 12 lines
On Tue, 14 Sep 2004, Darek Mazur wrote: > HI > > I need that WRITELN make the same end of line in Linux and Win32, > > I found sLineBreak, but for some OS it is var, for some const, > > There is second identifier LineEnding (mostly const) > > I think, tha one should be const, and second var, and when somebody need

changes

> behavour of WRITELN that he can do it. The purpose of this constant is not to be able to set the lineending, it gives the lineending which is the default on the current platform.

I know, but why are two identifiers

If you need to have the same lineending on all platforms, you must do your writes yourself. I would suggest using TStreams then.

I can do it, but I have to change many lines of code (many thousand lines), thats trouble

Show quoted text 8 lines
Michael. _______________________________________________ fpc-devel maillist - http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply by email

Michael Van Canneyt
to Darek M
Darek M wrote 19 lines
> > On Tue, 14 Sep 2004, Darek Mazur wrote: > > > HI > > > > I need that WRITELN make the same end of line in Linux and Win32, > > > > I found sLineBreak, but for some OS it is var, for some const, > > > > There is second identifier LineEnding (mostly const) > > > > I think, tha one should be const, and second var, and when somebody need changes > > behavour of WRITELN that he can do it. > > The purpose of this constant is not to be able to set the lineending, it > gives the lineending which is the default on the current platform. I know, but why are two identifiers

One of the two is for Delphi compatibility.

If I remember correctly, LineEnding is the FPC constant. sLineBreak comes from Delphi/Kylix

Show quoted text 5 lines
> If you need to have the same lineending on all platforms, you must do > your writes yourself. I would suggest using TStreams then. I can do it, but I have to change many lines of code (many thousand lines), thats trouble

I think that if your code expects the same linefeed on both platforms, you should rethink your strategy. You should always use the 'local' default. Opening a unix LF file in Windows gives strange results, and vice versa too...

Michael.

Reply by email

Darek Mazur
to Michael Van Canneyt
Użytkownik Michael Van Canneyt wrote 7 lines
I think that if your code expects the same linefeed on both platforms, you should rethink your strategy. You should always use the 'local' default. Opening a unix LF file in Windows gives strange results, and vice versa too...

I dont agree:
I don't know on which OS file will be write or read, I have several places to generate and several to read files. And no user need to open this files myself without application.

And second I don't understand why You don't want change it. I don't see any true reason to left it unchanged. Everybody, who want to control output must avoid WRITELN (I don't test READLN, but I use it very rare). I want do decide, how function work, not OS.

Of course I can do it by hand, but I think that somebody help me (I must change more than 1000 places in my program)

Darek

Show quoted text 8 lines
Michael. _______________________________________________ fpc-devel maillist - http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply by email

Tomas Hajny
to Darek Mazur

On Wed, 15 Sep 2004 23:59:57 +0200, Darek Mazur wrote

Show quoted text 11 lines
Użytkownik Michael Van Canneyt napisał: > > I think that if your code expects the same linefeed on both platforms, > you should rethink your strategy. You should always use the 'local' > default. Opening a unix LF file in Windows gives strange results, and > vice versa too... I dont agree: I don't know on which OS file will be write or read, I have several places to generate and several to read files. And no user need to open this files myself without application.

If it's only your application working with these files, you are already on the safe side, because FPC supports all line endings on all supported platforms.

Show quoted text 7 lines
And second I don't understand why You don't want change it. I don't see any true reason to left it unchanged. Everybody, who want to control output must avoid WRITELN (I don't test READLN, but I use it very rare). I want do decide, how function work, not OS. Of course I can do it by hand, but I think that somebody help me (I must change more than 1000 places in my program)

We will discuss this internally and let you know the result.

Tomas

Reply by email

Darek Mazur
to Tomas Hajny
Użytkownik Tomas Hajny wrote 17 lines
On Wed, 15 Sep 2004 23:59:57 +0200, Darek Mazur wrote >Użytkownik Michael Van Canneyt napisał: > >>I think that if your code expects the same linefeed on both platforms, >>you should rethink your strategy. You should always use the 'local' >>default. Opening a unix LF file in Windows gives strange results, and >>vice versa too... > >I dont agree: > I don't know on which OS file will be write or read, I have >several places to generate and several to read files. And no user >need to open this files myself without application. If it's only your application working with these files, you are already on the safe side, because FPC supports all line endings on all supported platforms.

I know.

Show quoted text 13 lines
> And second I don't understand why You don't want change it. I >don't see any true reason to left it unchanged. Everybody, who want >to control output must avoid WRITELN (I don't test READLN, but I use >it very rare). I want do decide, how function work, not OS. > >Of course I can do it by hand, but I think that somebody help me (I >must change more than 1000 places in my program) We will discuss this internally and let you know the result.

Thx, that sounds good.

Show quoted text 9 lines
Tomas _______________________________________________ fpc-devel maillist - http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply by email

Tomas Hajny
to Darek Mazur

From: Darek Mazur
To:
Subject: Re: [fpc-devel]const sLineBreak
Send reply to:

Date sent: Thu, 16 Sep 2004 16:52:54 +0200

Show quoted text 5 lines
Użytkownik Tomas Hajny napisał: > On Wed, 15 Sep 2004 23:59:57 +0200, Darek Mazur wrote > >>Użytkownik Michael Van Canneyt napisał: >>

.
.

Show quoted text 12 lines
>> And second I don't understand why You don't want change it. I >>don't see any true reason to left it unchanged. Everybody, who want >>to control output must avoid WRITELN (I don't test READLN, but I use >> it very rare). I want do decide, how function work, not OS. >> >>Of course I can do it by hand, but I think that somebody help me (I >>must change more than 1000 places in my program) > > > We will discuss this internally and let you know the result. Thx, that sounds good.

A new procedure SetTextLineEnding (var T: text; S: string) was added to System unit in CVS. This allows you to change line ending for individual text files. After call to Assign the line ending for that file is set to the default line ending on your platform, then you can change the default value using the newly provided procedure - since that time all WriteLn calls will use your new value. Changing the default value system-wide would be dangerous because of output to console, redirection, libraries possibly expecting particular behaviour etc.

Tomas

Reply by email

Vincent Snijders
to Darek Mazur: That is better solution, than I think . But is function like GetTextLineEnding(vat T:…
Darek Mazur wrote 17 lines
Użytkownik Tomas Hajny napisał: > A new procedure SetTextLineEnding (var T: text; S: string) was added > to System unit in CVS. This allows you to change line ending for > individual text files. After call to Assign the line ending for that > file is set to the default line ending on your platform, then you can > change the default value using the newly provided procedure - since > that time all WriteLn calls will use your new value. Changing the > default value system-wide would be dangerous because of output to > console, redirection, libraries possibly expecting particular > behaviour etc. That is better solution, than I think . But is function like GetTextLineEnding(vat T: text): string

This is not really necessary. If you rewrite or append the file it has the System.LineEnding as line ending. You are the one who changes it with SetTextLineEnding and if you have done it, you know what you changed it to. If you haven't called SetTextLineEnding, it is still the default: System.LineEnding.

Regards,
Vincent.

Reply by email

Tomas Hajny
to Darek Mazur: That is better solution, than I think . But is function like GetTextLineEnding(vat T:…

On Wed, 22 Sep 2004 11:51:06 +0200, Darek Mazur wrote

Użytkownik Tomas Hajny napisał: > From: Darek Mazur > Date sent: Thu, 16 Sep 2004 16:52:54 +0200

.
.

Show quoted text 16 lines
> A new procedure SetTextLineEnding (var T: text; S: string) was added > to System unit in CVS. This allows you to change line ending for > individual text files. After call to Assign the line ending for that > file is set to the default line ending on your platform, then you can > change the default value using the newly provided procedure - since > that time all WriteLn calls will use your new value. Changing the > default value system-wide would be dangerous because of output to > console, redirection, libraries possibly expecting particular > behaviour etc. That is better solution, than I think . But is function like GetTextLineEnding(vat T: text): string I don check CVS yet

Such a function can be added, of course, but keep in mind that it will only return the value you assigned to it yourself (as already mentioned by Vincent). Don't expect that it would be able to determine the used line ending type in existing files while reading them - this is not possible (among other reasons, you are never guaranteed to have uniform line endings throughout the whole existing file).

Tomas

Reply by email

Darek Mazur
to Tomas Hajny: From: Darek Mazur To: Subject: Re: [fpc-devel]const sLineBreak Send…
Użytkownik Tomas Hajny wrote 43 lines
From: Darek Mazur To: Subject: Re: [fpc-devel]const sLineBreak Send reply to: Date sent: Thu, 16 Sep 2004 16:52:54 +0200 >Użytkownik Tomas Hajny napisał: > >>On Wed, 15 Sep 2004 23:59:57 +0200, Darek Mazur wrote >> >> >>>Użytkownik Michael Van Canneyt napisał: >>> . . >>> And second I don't understand why You don't want change it. I >>>don't see any true reason to left it unchanged. Everybody, who want >>>to control output must avoid WRITELN (I don't test READLN, but I use >>>it very rare). I want do decide, how function work, not OS. >>> >>>Of course I can do it by hand, but I think that somebody help me (I >>>must change more than 1000 places in my program) >> >> >>We will discuss this internally and let you know the result. > >Thx, that sounds good. A new procedure SetTextLineEnding (var T: text; S: string) was added to System unit in CVS. This allows you to change line ending for individual text files. After call to Assign the line ending for that file is set to the default line ending on your platform, then you can change the default value using the newly provided procedure - since that time all WriteLn calls will use your new value. Changing the default value system-wide would be dangerous because of output to console, redirection, libraries possibly expecting particular behaviour etc.

That is better solution, than I think .

But is function like
GetTextLineEnding(vat T: text): string

I don check CVS yet

Darek

Show quoted text 9 lines
Tomas _______________________________________________ fpc-devel maillist - http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply by email

Tomas Hajny
to Darek Mazur: Of course, I don't expect test of format of file. I think, this function is need when…

On Wed, 22 Sep 2004 13:32:27 +0200, Darek Mazur wrote

Show quoted text 12 lines
Użytkownik Tomas Hajny napisał: > On Wed, 22 Sep 2004 11:51:06 +0200, Darek Mazur wrote > >>Użytkownik Tomas Hajny napisał: >> >>>From: Darek Mazur >>>Date sent: Thu, 16 Sep 2004 16:52:54 +0200 > > . > . >>>A new procedure SetTextLineEnding (var T: text; S: string) was added >>>to System unit in CVS. This allows you to change line ending for

.
.

>>But is function like >> GetTextLineEnding(vat T: text): string

.
.

Show quoted text 9 lines
> Such a function can be added, of course, but keep in mind that it will only > return the value you assigned to it yourself (as already mentioned by > Vincent). Don't expect that it would be able to determine the used line ending > type in existing files while reading them - this is not possible (among other > reasons, you are never guaranteed to have uniform line endings throughout the > whole existing file). Of course, I don't expect test of format of file. I think, this function is need when pass T:text to other function

Why do you think this function is needed (sample scenario)?

Tomas

Reply by email

Darek Mazur
to Tomas Hajny: On Wed, 22 Sep 2004 11:51:06 +0200, Darek Mazur wrote . . Such a function can be added,…
Użytkownik Tomas Hajny wrote 34 lines
On Wed, 22 Sep 2004 11:51:06 +0200, Darek Mazur wrote >Użytkownik Tomas Hajny napisał: > >>From: Darek Mazur >>Date sent: Thu, 16 Sep 2004 16:52:54 +0200 . . >>A new procedure SetTextLineEnding (var T: text; S: string) was added >>to System unit in CVS. This allows you to change line ending for >>individual text files. After call to Assign the line ending for that >>file is set to the default line ending on your platform, then you can >>change the default value using the newly provided procedure - since >>that time all WriteLn calls will use your new value. Changing the >>default value system-wide would be dangerous because of output to >>console, redirection, libraries possibly expecting particular >>behaviour etc. > >That is better solution, than I think . > >But is function like > GetTextLineEnding(vat T: text): string > >I don check CVS yet Such a function can be added, of course, but keep in mind that it will only return the value you assigned to it yourself (as already mentioned by Vincent). Don't expect that it would be able to determine the used line ending type in existing files while reading them - this is not possible (among other reasons, you are never guaranteed to have uniform line endings throughout the whole existing file).

Of course, I don't expect test of format of file. I think, this function is need when pass T:text to other function

My ask:
Is SetTextLineEnding applied to readln (I can test it)

Darek

Show quoted text 9 lines
Tomas _______________________________________________ fpc-devel maillist - http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply by email

Jonas Maebe
to Darek Mazur: I only imagine (sorry for my english), when I set something that sometimes I must read…
Darek Mazur wrote
I can't now give an exact program, but this kind of function don't make any disorder or other bad things.

The main problem is that people may expect it to return the line-endings of the text file, instead of just what you set it to be. As such, it can cause confusion. Just like some properties of an object can be read-only, some can be write-only as well. I also can't think of any situation where you would want to write something different to the file based on the set line endings.

Jonas

Reply by email

Darek Mazur
to Tomas Hajny: On Wed, 22 Sep 2004 13:32:27 +0200, Darek Mazur wrote . . . . Why do you think this…
Użytkownik Tomas Hajny wrote 40 lines
On Wed, 22 Sep 2004 13:32:27 +0200, Darek Mazur wrote >Użytkownik Tomas Hajny napisał: > >>On Wed, 22 Sep 2004 11:51:06 +0200, Darek Mazur wrote >> >> >>>Użytkownik Tomas Hajny napisał: >>> >>> >>>>From: Darek Mazur >>>>Date sent: Thu, 16 Sep 2004 16:52:54 +0200 >> >> . >> . >> >>>>A new procedure SetTextLineEnding (var T: text; S: string) was added >>>>to System unit in CVS. This allows you to change line ending for . . >>>But is function like >>> GetTextLineEnding(vat T: text): string . . >>Such a function can be added, of course, but keep in mind that it will only >>return the value you assigned to it yourself (as already mentioned by >>Vincent). Don't expect that it would be able to determine the used line ending >>type in existing files while reading them - this is not possible (among other >>reasons, you are never guaranteed to have uniform line endings throughout the >>whole existing file). > >Of course, I don't expect test of format of file. I think, this >function is need when pass T:text to other function Why do you think this function is needed (sample scenario)?

I only imagine (sorry for my english), when I set something that sometimes I must read what I set. For me T: text is like object, which I pass to function, this function maybe need to know, how Lineending is set (I think about special or internal function). Its not correct pass to this function LineEnding separately. I think that every kind of information about T:text should be set and get through function/procedures not direct from fields of record.

I can't now give an exact program, but this kind of function don't make any disorder or other bad things.

Darek

Show quoted text 10 lines
Tomas _______________________________________________ fpc-devel maillist - http://lists.freepascal.org/mailman/listinfo/fpc-devel .

Reply by email

Darek Mazur
to Jonas Maebe: The main problem is that people may expect it to return the line-endings of the text…

Uz.ytkownik Jonas Maebe napisa?:

Show quoted text 9 lines
On 22 sep 2004, at 16:07, Darek Mazur wrote: > I can't now give an exact program, but this kind of function don't > make any disorder or other bad things. The main problem is that people may expect it to return the line-endings of the text file, instead of just what you set it to be.

This is for developer, not for users ?
When I found new function, I test it and read manual. In whole FPC is many similar names of different function and nobody should think about function only from its name. Of course better is, when names are full of knowledge (I don't know how it say), but it can't be a barrier of development.

My idea: change name (settextlineending too) or make second function GetFileLineEnding to return line-endings of file.

As such, it can

Show quoted text 14 lines
cause confusion. Just like some properties of an object can be read-only, some can be write-only as well. I also can't think of any situation where you would want to write something different to the file based on the set line endings. Jonas _______________________________________________ fpc-devel maillist - http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply by email