Search code examples
inno-setuppascalscript

Declaring variable in Inno Setup Pascal Script


I have added the following code to my script:

[Code]
function IsSomeAppInstalled: Boolean;
begin
  Result := FileExists(ExpandConstant('{pf32}\SomeApp\Some.dll'));
end;

function InitializeSetup(): Boolean;
begin
   Boolean bIsInstalled := IsSomeAppInstalled();
   MsgBox('IsSomeAppInstalled: ' + IntToStr(Integer(bIsInstalled)),
     mbInformation, MB_OK);
   Result := true;
end;

The line

Boolean bIsInstalled := IsSomeAppInstalled();

raises the error

Internal error (20)

What might be the error here?


Solution

  • In Pascal (Script) you declare variables using var keyword before the actual code:

    function InitializeSetup(): Boolean;
    var
      bIsInstalled: Boolean;
    begin
      bIsInstalled := IsSomeAppInstalled();
      MsgBox('IsSomeAppInstalled: ' + IntToStr(Integer(bIsInstalled)),
        mbInformation, MB_OK);
      Result := true;
    end;