Recent

Author Topic: Multiple lines strings?  (Read 6455 times)

Ricardo T.

  • New Member
  • *
  • Posts: 13
Multiple lines strings?
« on: October 17, 2018, 07:57:23 am »
Hello u all... Hope everyone is doing ok...  ;)

How to write a multiple line string in the constant section without messing up the indentation in the code?

Like in Python you can do a triple quote string """.......""" that can be several lines in length.Can i do something similar in FPC?

Do i also have to declare it as an Ansistring?

Thanks...

Handoko

  • Hero Member
  • *****
  • Posts: 5130
  • My goal: build my own game engine using Lazarus
Re: Multiple lines strings?
« Reply #1 on: October 17, 2018, 08:30:55 am »
Code: Pascal  [Select][+][-]
  1. const
  2.   S = 'Good Morning everyone.'       + LineEnding +
  3.       'Welcome to the Pascal forum!' + LineEnding +
  4.       'Here you will meet many nice people.';

Read more about LineEnding:
http://wiki.freepascal.org/End_of_Line

Note:
Pascal is not strict about indentation. The code above can be rewrited as:
Code: Pascal  [Select][+][-]
  1. const
  2.   Something = 'Good Morning everyone.' + LineEnding +
  3.     'Welcome to the Pascal forum!' + LineEnding +
  4.     'Here you will meet many nice people.';
« Last Edit: October 17, 2018, 08:43:03 am by Handoko »

Ricardo T.

  • New Member
  • *
  • Posts: 13
Re: Multiple lines strings?
« Reply #2 on: October 17, 2018, 09:22:04 am »
Handoko... Thank U Sir.  I will give it a try...  :D

 

TinyPortal © 2005-2018