PDA

View Full Version : Function problem



Amichie
09-07-2014, 02:46 PM
Main loop:


result := findPapaya();
writeLn(result);


findPapaya:


function findPapaya(): boolean;
var
x, y: integer;
begin
if mainscreen.findObject(x, y, 2341762, 15, ['Take Papaya fruit'], MOUSE_MOVE) then
begin
Result := true;
writeLn('We found a papaya!');
writeLn(Result);
end else
writeLn('Failed to find another papaya.');
Result := false;
end;


The problem is: inside the findPapaya function Result is TRUE, but in the main loop the writeLn writes FALSE in the debug box.

riwu
09-07-2014, 02:50 PM
add a begin and end for your last 2 statements:

end else
begin
writeLn('Failed to find another papaya.');
Result := false;
end;

Amichie
09-07-2014, 02:55 PM
Worked, thanks! :=)