If I have to write a lot of lines I personally use a macro:
{$Macro On} {$Define ln:=+LineEnding+} const MyString = 'Line1'ln 'Line2'ln 'Line3'ln 'Line3';
There is actually a patch for that, that I tested and confirmed to work, but it used back-ticks..
Unless, of course, somebody would like to argue that comments should be moved out of the unit and into a file of their own?They should be put in the cloud or better yet, ai generated. Now let's try that with some SQL :D
I have inline var syndrome, mind... Silly idiots.
Then are there also smart idiots? :)That is named idiot savant (https://en.wiktionary.org/wiki/idiot_savant) :)
I understand your irritation towards Delphi developers. But in Delphi, the following are much more irritating (for example):
Delphi 12.0 introduced Multi-line String Literals (https://docwiki.embarcadero.com/RADStudio/en/String_Types_(Delphi)#Long_and_Multiline_String_Literals), for example:
const MyString = ''' Line1 Line2 Line3 Line4 ''';
Maybe FreePascal will add something like this someday.
The Delphi case should be refused too...
I have inline var syndrome, mind... Silly idiots.
[…] S := 'This is a' + LineEnding + 'multiple line string' + LineEnding + 'in Pascal.'; […]
[…]
[…]NB: This makes the last “line” a degenerate line, an incomplete line. A line is a (possibly empty) sequence of char values (except those of the end‑of‑line character sequence) followed by one end‑of‑line character sequence.
No, multi‑line strings are by definition not possible. A string is a sequence of char values along one dimension.
No, multi‑line strings are by definition not possible.is talking nonsense.
Lazarus provides a very nice way for entering multiline strings.
Seems that not many people use it just because the name of the menu item in the IDE is not very intuitive.
The details: https://forum.lazarus.freepascal.org/index.php/topic,52669.msg388780.html#msg388780 (https://forum.lazarus.freepascal.org/index.php/topic,52669.msg388780.html#msg388780)
There is actually a patch for that, that I tested and confirmed to work, but it used back-ticks..
Which visually is probably not a bad choice: sequences of '""' etc. "get old fast".
I know that the core team is inclined to tell us to put multilines into resource files, but I maintain- impenitently and from experience- that they are wrong. If you're writing Pascal code that relies on- for example- an SQL fragment, the place to put that fragment is adjacent to the associated Pascal: and that's also the place to put the comments explaining what the combination is doing.
Unless, of course, somebody would like to argue that comments should be moved out of the unit and into a file of their own?
For code fragments moving them to a separate file has the advantage that an IDE can easily syntax highlight them or provide refactoring features. With code embedded as part of other code this becomes harder.