1

When I define a preprocessor string variable (using the ISPP) that contains a quote/apostrophe, there will be a compiler error when I use the function ExpandConstant in the [Code] section to read this string.

Here's an example .iss script for demonstrating/testing:

#define _AppName "Uli's Program"

[Setup]

AppName={#_AppName}
AppVersion=1.2.3
DefaultDirName={pf}\{#_AppName}

[Code]

function InitializeSetup: Boolean;
begin
  MsgBox(ExpandConstant('{#_AppName}'),
         mbInformation,
         MB_OK);
  Result:=False;
end;

The exact compiler error message is:

comma (',') expected.

Update

This works when the apostrophe is doubled. But now the captions of the wizard pages show the app name with a double apostrophe (because of AppName={#_AppName}).

A similar issue occurs when the #define is removed and the script is altered this way:

[Setup]

AppName=Uli's Program
AppVersion=1.2.3
DefaultDirName={pf}\{#AppName}

[Code]

function InitializeSetup: Boolean;
begin
  MsgBox('{#SetupSetting("AppName")}'),
         mbInformation,
         MB_OK);
  Result:=False;
end;

Now the compiler error message is

Assignment expected.

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
uliF
  • 31
  • 2

1 Answers1

0

You can use the macro to create an entry in CustomMessages section.

And then load the custom message in Pascal Script using CustomMessage function.

#define _AppName "Uli's Program"

[CustomMessages]
MyAppName={#_AppName}

[Code]

function InitializeSetup(): Boolean;
begin
  MsgBox(CustomMessage('MyAppName'), mbInformation, MB_OK);
  Result := False;
end;

Another (rather hackish) way is to use StringChange preprocessor function to double the quote in Pascal Script.

#define _AppName "Uli's Program"

[Code]

function InitializeSetup(): Boolean;
begin
  MsgBox('{#StringChange(_AppName, "'", "''")}', mbInformation, MB_OK);
  Result := True;
end;

Note that I do not use ExpandConstant to resolve the preprocessor variable/expression - It's nonsense. See Evaluate preprocessor macro on run time in Inno Setup Pascal Script.


enter image description here

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