inno-setuppascalscript

Getting compile error "Semicolon (;) expected" when initializing variable in Inno Setup


I am writing Inno Setup script code for user input of Username and Password. I want to skip this page for user and take constant value for Username and Password.

For example username is 12345 want to make it constant initialization.

Here is my code.

var
  Username, Password: String;

When I modify this code like:

  Username : String = '12345';
  Password : String = 'MyPassword';

I'm getting compile error:

Semicolon (;) expected.

Could anyone please help me to fix it. I am newbie in Pascal.


Solution

  • Inno Setup Pascal Script does not support initializing variables at a point of their declaration.

    Initialize them in the InitializeSetup event function instead.

    var
      Username, Password: string;
    
    function InitializeSetup(): Boolean;
    begin
      Username := '12345';
      Password := 'MyPassword';
    
      Result := True;
    end;
    

    A related question: Are global variables in Pascal Script zero-initialized?


    Note that your code would be correct in Pascal/Delphi. But this is Pascal Script, not Pascal.