Martin Prikryl
Martin Prikryl

Reputation: 202128

Emit new line in Inno Setup preprocessor

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?

Upvotes: 3

Views: 1627

Answers (2)

Martin Prikryl
Martin Prikryl

Reputation: 202128

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+

Upvotes: 2

splash
splash

Reputation: 13327

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.

Upvotes: 1

Related Questions