Reputation: 473
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
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