3

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?

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992

2 Answers2

2

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+
Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
1

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.

splash
  • 13,037
  • 1
  • 44
  • 67
  • I arrived to the same conclusion when looking at the code. But I just could not believe that the default string type has such a limitation. – Martin Prikryl Nov 01 '17 at 09:20