3

I need to determine the value of the WizardStyle setup directive for a conditional in my Pascal Script section. To do something like this:

if WizardStyle = "Modern" then
begin
    // Code to run for "modern" style.
end
else if WizardStyle = "Classic" then
begin
    // Code to run for "classic" style.
end;

How can achieve this? This does not seem to work: ExpandConstant('{WizardStyle}')

I have read this, but I don't take things in clear about how to determine the value of this directive:

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
ElektroStudios
  • 19,105
  • 33
  • 200
  • 417

2 Answers2

3

While your answer works, it actually makes little sense to check a compile time directive value on run-time. In your case the run-time check penalty is low, so it does not really matter. But in general, do check on compile-time.

For example:

#if LowerCase(SetupSetting("WizardStyle")) == "modern"
// Code to run for "modern" style
#else
// Code to run for "classic" style.
#endif

Another approach:

// Remove or comment out for the default "classic" style
#define UseModernWizardStyle
[Setup]
#ifdef UseModernWizardStyle
WizardStyle=modern
#endif
#ifdef UseModernWizardStyle
// Code to run for "modern" style.
#else
// Code to run for "classic" style
#endif
Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
2

I've found the solution in this doc:

With a usage example in the [Code] section of this other doc:

So this is how one can do it to obtain the value:

procedure InitializeWizard();
var
  WizardStyle: String;

begin
  WizardStyle := LowerCase('{#SetupSetting("WizardStyle")}'); // "modern" or "classic"

  if WizardStyle = 'modern' then
  begin
    // Code to run for "modern" style.
  end
  else if WizardStyle = 'classic' then
  begin
    // Code to run for "classic" style.
  end;

end;
Andrew Truckle
  • 17,769
  • 16
  • 66
  • 164
ElektroStudios
  • 19,105
  • 33
  • 200
  • 417