You are calling your main loop from INSIDE the form, and thats why SCAR is freezing. Since you have not told the form to close and actually start the script, SCAR is getting a bit confised as it is being told to do 2 things at once, hence it freezes.
Main loops shouldn't be a Sender, just a normal procedure.
try using this template for forms:
PHP Code:
//Global var, so that if the start button isn't clicked, the script will terminate
Var
ScriptStart: Boolean;
//All smalltime procedures and functions here
procedure one;
begin
end;
function two: integer;
begin
result := 2;
end;
//Main loop here
Procedure MainLoop;
begin
If (two = 2) then
one;
end;
//usual boring code for safe calling the form up
Procedure SafeInitForm;
var
v: TVariantArray;
begin
setarraylength(V, 0);
ThreadSafeCall('InitForm', v);
end;
procedure ShowFormModal;
begin
frmDesign.ShowModal;
end;
procedure SafeShowFormModal;
var
v: TVariantArray;
begin
setarraylength(V, 0);
ThreadSafeCall('ShowFormModal', v);
end;
//Personal options such as Saving settings, Clicking buttons, Converting form components to Variables
Procedure ComponentsToVariables;
begin
end;
procedure Start(sender: TObject);
begin
frmDesign.Caption:= frmDesign.Caption + '.';
ComponentsToVariables;
ScriptStart := True; //The button has been pressed, therefore it is alright to start the script
frmDesign.ModalResult:= mrOk;
end;
//Displaying and setting form components how you want them:
Procedure InitForm;
begin
//...
end;
//Anything else, such as minimising, maximizing etc.
procedure MainInitForm;
begin
try
SafeInitForm;
SafeShowInitFormModal;
finally
FreeForm(frmDesign);
except
WriteLn('Error in InitForm!');
end;
end;
// Kaitnieks' SetSelfWindowState
procedure SetSelfWindowState(state: TWindowState);
begin
GetSelf.WindowState := state;
end;
// Kaitnieks' SafeSetSelfWindowState
procedure SafeSetSelfWindowState(state: TWindowState);
var
V: TVariantArray;
begin
SetArrayLength(V, 1);
V[0] := state;
ThreadSafeCall('SetSelfWindowState', V);
end;
//main loop
begin
ClearDebug;
TimeInitForm := GetSystemTime;
SafeSetSelfWindowState(wsMinimized);
MainInitForm;
SafeSetSelfWindowState(wsNormal);
If (ScriptStart = False) then TerminateScript; //If the button wasn't pressed, then terminate script.
Mainloop; //Start the main loop!
end.
Hope that helps