SRL Archive - OSR Help

Got another one 'WaitFunc'


bud_wis_er_420

2013-02-18 23:27:50

Why is it when I try passing a variable thru the function I'm calling in the WaitFunc() function, I get a Type mismatch error.

I want to do this..

program new;
//{$DEFINE SMART}
{$I SRL/SRL.Simba}

function PassVar(i: integer): Boolean;
var
c: integer;
begin
result := false;
c := random(10);
if i = c then
result := true;
end;

Begin
setupSRL;
// () in this function *Error: Type mismatch
if WaitFunc(@PassVar(8), 250, 1000) then
writeln('Found number')
else writeln('Number not found')
End.

But instead I have to do this…

program new;
//{$DEFINE SMART}
{$I SRL/SRL.Simba}

function PassVar(i: integer): Boolean;
var
c: integer;
begin
result := false;
c := random(10);
if i = c then
result := true;
end;

function PassVarForward: Boolean;
begin
result := false;
if PassVar(8) then
result := true;
end;


Begin
setupSRL;
// No () in this function
if WaitFunc(@PassVarForward, 250, 1000) then
writeln('Found number')
else writeln('Number not found')
End.

Le Jingle

2013-02-19 00:11:59

I forget how wait func ex works, but I think it's along the lines of:

program new;
{$include_once srl/srl.simba}

function PassVar(i : integer): Boolean;
begin
result := (i = random(10));
end;

var
throw : TVariantArray;

begin
SetupSRL;
SetLength(throw, 1);
throw[0] := 5;
if WaitFuncEx('PassVar', throw, 25, 5000) then
writeln('found')
else
writeln('not found');
end.

Iirc, the TVariantArray is for the args of the function you call

bud_wis_er_420

2013-02-19 00:24:30

no, I'm trying to pass a var into the inner function not get one from it. like this

WaitFunc(@IsUpText('Cow'),RandomRange(200,220), RandomRange(900,1000))

edit: wait a min ex huh give me a sec to look into that one.


Ok I see now, Thx again

program new;
//{$DEFINE SMART}
{$I SRL/SRL.Simba}

function PassVar(i: integer): Boolean;
var
c: integer;
begin
result := false;
c := random(10);
if i = c then
result := true;
end;

var
V: TVariantArray;
Begin
setupSRL;
// () in this function *Error: Type mismatch
V := [8];
if WaitFuncEX('PassVar', V, 250, 1000) then
writeln('Found number')
else writeln('Number not found')
End.