3
votes

When using Inno Setup preprocessor to generate a multi-line output, like for example in these answers of mine:

I always have to switch to the C-style string literals using #pragma parseroption directive, because with C-style string literals, I can use \n:

#pragma parseroption -p-

#define TwoLines "line1\nline2\n"

#pragma parseroption -p+

I haven't found any way to emit a new-line character in the default Pascal-style string literals.

In a real Pascal (Script) string, one can use #13#10. But that does not work in the preprocessor. Neither there's an equivalent of Pascal Chr function.

Is there any other way to emit a new line in the Pascal-style string literals?

2
Do you mean const string literals like that: const myString = 'this is a long string that extends' + 'to a second line';? - DeadTrousers
@DeadTrousers No, preprocessor literal. Like #define FileEntry(Source) "Source: " + Source + "; DestDir: {app}\n". See more examples in the linked questions. - Martin Prikryl

2 Answers

2
votes

There's NewLine macro available in Inno Setup 6.


If you are on an older version of Inno Setup, you can define the macro in your own script. It's defined as:

#pragma parseroption -p-
#define NewLine "\n"
#pragma parseroption -p+
1
votes

I took a look at the source code of the Inno Setup Preprocessor:

https://github.com/jrsoftware/issrc/tree/master/Projects/ISPP

I think there is no other way than yours. The preprocessor is mainly based on a C tokenizer and the parseroption -p basically just enables/disables the support for escape sequences. But there is no implementation for parsing Pascal character literals like #13#10.