Maiken Roskilde
Maiken Roskilde

Reputation: 473

Inno-Setup Semicolon missing

I have the following function which results in an "Semicolon missing." error", but I don't see why.

Thank you for the help!

 function PrepareToInstall(var NeedsRestart: Boolean): String;
begin
   if not IsServiceRunning('oscmaintenanceserver') then
       begin
           MsgBox('Service not running. Exit.', mbInformation, MB_OK);
           exit;
       end
   end
   if not StopService('oscmaintenanceserver') then
       begin
           MsgBox('Service couldnt be stopped.', mbInformation, MB_OK);
           exit;
       end
   end
   if not RemoveService('oscmaintenanceserver') then
       begin
           MsgBox('Couldnt remove service.', mbInformation, MB_OK);
           exit;
       end
   end   
   begin
       MsgBox('All went fine :-).', mbInformation, MB_OK);
       exit;
   end
end;

Upvotes: 1

Views: 150

Answers (1)

Sertac Akyuz
Sertac Akyuz

Reputation: 54832

You've got an extra end in each if branch. Additionally, when marking an end of a statement, an end requires a semicolon after it.

 function PrepareToInstall(var NeedsRestart: Boolean): String;
begin
   if not IsServiceRunning('oscmaintenanceserver') then
       begin
           MsgBox('Service not running. Exit.', mbInformation, MB_OK);
           exit;
       end;
   if not StopService('oscmaintenanceserver') then
   ...

Upvotes: 3

Related Questions