Thanks, works :)
function WaitFunc(Func:string; Args : array of Variant; WaitTime,MaxTime : integer): boolean;
var t: integer;
begin
t := GetTimeRunning();
while (t+MaxTime > GetTimeRunning()) do
begin
Result := variantInvoke(Func,Args);
if Result then exit;
Wait(WaitTime);
end;
end;
@EDIT
I caught a vein:
function WaitFuncNumber(Func:string; Args : array of Variant; WaitTime,MaxTime:integer; Relation:string;Number:integer ): boolean;
var t,b: integer;
begin
t := GetTimeRunning();
while (t+MaxTime > GetTimeRunning()) do
begin
case Relation of
'=': Result := variantInvoke(Func,Args) = Number;
'<>': Result := variantInvoke(Func,Args) <> Number;
'>': Result := variantInvoke(Func,Args) > Number;
'<': Result := variantInvoke(Func,Args) < Number;
'<=': Result := variantInvoke(Func,Args) <= Number;
'>=': Result := variantInvoke(Func,Args) >= Number;
end;
if Result then exit;
Wait(WaitTime);
end;
end;
That waits till output of the function achieves defined relation, for example: you can wait till number of red pixels in some box >= 100.
Example:
program new;
function W(a:integer) : integer;
begin
Result := a;
end;
function WaitFuncNumber(Func:string; Args : array of Variant; WaitTime,MaxTime:integer; Relation:string;Number:integer ): boolean;
var t,b: integer;
begin
t := GetTimeRunning;
while (t+MaxTime > GetTimeRunning) do
begin
case Relation of
'=': Result := variantInvoke(Func,Args) = Number;
'<>': Result := variantInvoke(Func,Args) <> Number;
'>': Result := variantInvoke(Func,Args) > Number;
'<': Result := variantInvoke(Func,Args) < Number;
'<=': Result := variantInvoke(Func,Args) <= Number;
'>=': Result := variantInvoke(Func,Args) >= Number;
end;
if Result then exit;
Wait(WaitTime);
end;
end;
var a:integer;
begin
a := 4;
writeln ( WaitFuncNumber('W',[a],10,2000,'>',10) );
end.