SRL Archive - Help

Calling a function in a function


Nexz

2012-12-08 21:15:47

function WaitUntil(Something: Boolean): Boolean;
begin
repeat until Something;
Result := True;
end;
The above example will, in case I use it like this:
WaitUntil(FindColor(X, Y, 0, 0, 0, 0, 0));
set
Something: Boolean
to True or False and then do
repeat until Something;
which will loop endlessly because
Something: Boolean
keeps it's value forever.

But what I want is the function WaitUntil to repeat executing
FindColor(X, Y, 0, 0, 0, 0, 0)
every time it checks the value of
Something: Boolean
at
repeat until Something;
so that it would function like:
function WaitUntil2: Boolean;
begin
repeat until FindColor(X, Y, 0, 0, 0, 0, 0);
Result := True;
end;
(but WaitUntil2 doesn't allow you to give any imput like WaitUntil does)

Is it possible, and how?

Ps. I'm sorry if this is a weird post but I don't know how to explain this in a better way and I just got stuck and couldn't find anything about this.

Nebula

2012-12-08 21:17:51

Just use WaitFuncEx?

Brandon

2012-12-08 21:19:28


Function WaitUntil: Boolean;
var
X, Y: Integer;
begin
Repeat
//Do something here..
Until(FindColor(X, Y, 255, MIX1, MIY1, MIX2, MIY2));
end;


Function WaitUntil(Something: function: Boolean): Boolean;
var
X, Y: Integer;
begin
Repeat
Until(Something());
end;


Function WaitUntil(Something: function(X, Y: Integer): Boolean): Boolean;
begin
Repeat
Until(Something(100, 100));
end;

Function Foo(X, Y: Integer): Boolean;
Begin
Writeln('Calling Foo through Something with parameters: ' + ToStr(X) + ' ' + ToStr(Y));
Result := True;
End;

begin
WaitUntil(@Foo);
end.

Nexz

2012-12-08 21:29:34

@ Nebula and Brandon
That's exactly what I was looking for. Thanks!