In Inno Setup Scripting (Pascal), how do you set a global variable's initial value?

Syndog picture Syndog · Feb 16, 2012 · Viewed 11k times · Source

(I'm pursuing Inno Setup scripting, but my understanding is that the [Code] section uses Pascal syntax, or a close approximation. I know zero about Pascal or its standard conventions, so apologies in advance for my ignorance.)

When defining a function/procedure's local variable, syntax for defining its initial value isn't such an issue...

procedure MyProcedure();
var
    aFlag: Boolean;
begin
    aFlag := true;
    .
    .
    .
end;

But I'm hard-pressed to figure out how the initial values for global variables are handled. For example, if I want a global Boolean variable to start out as true instead of false (the default), how would I go about accomplishing that?

Thanks!

Answer

Alex K. picture Alex K. · Feb 16, 2012

Define them inside the code block outside of a procedure:

[code]
var 
  wibble: boolean;
  wobble: string;
  ...

and you can set their initial values in the initialize event;

procedure InitializeWizard(); 
begin 
    wibble := true;
    wobble := "hello";
...