[fpc-devel] TStringList.Text and soTrailingLineBreak

michael michael at freepascal.org
Thu May 7 23:24:17 CEST 2026


On 2026-05-07 20:45, Bart via fpc-devel wrote:
> 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.


More information about the fpc-devel mailing list