Sign in Join

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

Mailing lists / fpc-devel / 2026-05

TStringList.Text and soTrailingLineBreak

2 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

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

Bart

Hi,

Some context.
I process text on the clipboard using a TStringList (too lazy to split it myself) and noticed that the last empty line went missing. (Empty lines in the input of this processing will be retruned as a TStringArray with empty strings, so missing the last empty input line matters.)

Experimented a bit.

  SL := TStringList.Create;
  writeln('soTrailingLineBreak in SL.Options=',soTrailingLineBreak in
SL.Options);
  SL.Text := 'A'+LineEnding;
  writeln('SL.Count=',SL.Ccount);

this will output:
SL.Count=1

I found it a little bit odd that the last (empty) line wasn't added to the stringlist.
I thought it might be dependant on wether or not soTrailingLineBreak was set in Options, but it doesn't.
Apparently soTrailingLineBreak only influences the result of GetTextStr.

Since I don't have Delphi anymore, I cannot test wether this is compatible or not.
I also could not find in Delphi docs wether soTrailingLineBreak should influence setting Text.

Bart

Reply by email

michael
to Bart
Bart wrote 31 lines
Hi, Some context. I process text on the clipboard using a TStringList (too lazy to split it myself) and noticed that the last empty line went missing. (Empty lines in the input of this processing will be retruned as a TStringArray with empty strings, so missing the last empty input line matters.) Experimented a bit. SL := TStringList.Create; writeln('soTrailingLineBreak in SL.Options=',soTrailingLineBreak in SL.Options); SL.Text := 'A'+LineEnding; writeln('SL.Count=',SL.Ccount); this will output: SL.Count=1 I found it a little bit odd that the last (empty) line wasn't added to the stringlist. I thought it might be dependant on wether or not soTrailingLineBreak was set in Options, but it doesn't. Apparently soTrailingLineBreak only influences the result of GetTextStr. Since I don't have Delphi anymore, I cannot test wether this is compatible or not. I also could not find in Delphi docs wether soTrailingLineBreak should influence setting Text.

It only influences get, never set.

Michael.

Reply by email