Welcome to the Tweaking4All community forums!
When participating, please keep the Forum Rules in mind!
Topics for particular software or systems: Start your topic link with the name of the application or system.
For example “MacOS X – Your question“, or “MS Word – Your Tip or Trick“.
Please note that switching to another language when reading a post will not bring you to the same post, in Dutch, as there is no translation for that post!
[Solved] Pascal - How to add a cross platform linebreak to a string
Delphi, Lazarus, Free Pascal
(@hans)
Famed Member Admin
Joined: 12 years ago
Posts: 2860
Topic starter
October 26, 2015 12:07 AM
In Lazarus Pascal, adding a cross platform line break to a string is easy, once you know that the constant "lineEnding" does that for you.
Under AppMethod (and Embarcadero RAD Studio), there is such a constant as well ... it's called "sLineBreak" and it is defined in the "System" unit (automatically used by you project).
For really old Delphi version, you could define this as such:
sLineBreak = {$IFDEF LINUX} AnsiChar(#10) {$ENDIF}
{$IFDEF MSWINDOWS} AnsiString(#13#10) {$ENDIF};
You can use it something like this:
Lazarus example:
label1.Caption := 'Line one'+lineEnding+'Line two';
AppMethod/RAD Studio (Delphi) example:
label1.Text := 'Line one'+sLineBreak+'Line two';