Recent

Author Topic: [SOLVED] Multi-platform Newline constant...  (Read 1045 times)

GypsyPrince

  • Guest
[SOLVED] Multi-platform Newline constant...
« on: April 04, 2020, 09:22:17 am »
Any suggestions on creating a multi-platform or platform independent solution for a Newline control constant - similar to .NET's 'System.Environment.NewLine'...?

This is a non-functional mockup of what I have in mind... just to convey what I'm looking for.

Code: Pascal  [Select][+][-]
  1. Const
  2.   {$IFDEF WINDOWS} //Microsoft Windows...
  3.       CTL_NEWLINE = #13#10;
  4.   {$ELSEIF MAC} //Mac OS classic...
  5.       CTL_NEWLINE = #13;
  6.   {$ELSEIF}  //Unix, Linux, Mac OSX, FreeBSD, and everything else...
  7.       CTL_NEWLINE = #10;
  8.   {$ENDIF}

Or, does OP/Lazarus already have something to serve this purpose?
« Last Edit: April 04, 2020, 09:37:57 am by GypsyPrince »

Handoko

  • Hero Member
  • *****
  • Posts: 5158
  • My goal: build my own game engine using Lazarus

Thaddy

  • Hero Member
  • *****
  • Posts: 14382
  • Sensorship about opinions does not belong here.
Re: Multi-platform Newline constant...
« Reply #2 on: April 04, 2020, 09:30:07 am »
It is already there and is called LineEnding
That is fully cross-platform, of course there is always the caveat that you need to be careful how a file is written/read from storage. That can have some side effects (e.g length).
@Handoko Posts crossed...
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

GypsyPrince

  • Guest
Re: Multi-platform Newline constant...
« Reply #3 on: April 04, 2020, 09:37:29 am »
Quote
It is already there and is called LineEnding
That is fully cross-platform...

Thank you! This was the info I needed.

 

TinyPortal © 2005-2018