6

Is there any command/construct like return in C that exits immediately from a function of Inno Setup script code keeping the result code?

I would like something

If k = false then
Begin
    Result:=false;
    Exit;
End;
Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
Maverick
  • 1,105
  • 12
  • 41

1 Answers1

5

Your code is correct.

Use the Exit statement to exit a function or a procedure. With the function, set the Result automatic variable, before you call the Exit, to set the return value.

function MyFunction: Boolean;
begin
  if not SomeTest then
  begin
    // cannot do stuff, aborting
    Result := False;
    Exit;
  end;

  // do stuff

  Result := True;
end;
Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992