why does this throw a mismatch error? http://pastebin.com/My4Cxw87
line 17
Printable View
why does this throw a mismatch error? http://pastebin.com/My4Cxw87
line 17
Calling function walkuntil is missing brackets.. Also the Record should be holding a boolean which is the return value of the function. I'm not too sure why you want to pass the function as a parameter rather than calling the global function directly. But oh well.. Up to you. The fix is below just in case you still want to call it via parameter.
Simba Code:type
RW_CheckPoint = Record
till: Boolean;
color,tolerance : Integer;
end;
function RW_noop : Boolean;
begin
Result := false;
end;
function RW_Point(c,t : Integer; WalkUntil : function : Boolean) : RW_CheckPoint;
begin
with Result do
begin
color := c;
t := tolerance;
till := WalkUntil();
end;
end;
Actual fix:
Simba Code:type
RW_TBoolFunc = function : Boolean;
RW_TPoint = Record
dir : extended;
till : RW_TBoolFunc;
color,tolerance : Integer;
end;
var
RW_Accuracy : Integer;
function RW_noop : Boolean;
begin
Result := false;
end;
procedure RW_setAccuracy(lvl : Integer);
begin
RW_Accuracy := lvl;
end;
procedure RW_setup;
begin
RW_setAccuracy(5);
end;
function RW_Point(direction : char;c,t : Integer; WalkUntil : RW_TBoolFunc) : RW_TPoint;
begin
with Result do
begin
color := c;
t := tolerance;
till := WalkUntil;
dir := variantToDirection(direction);
end;
end;
You will need to create a 'typedef' for function type. Thanks dgby :D
Looks no different from what I previously said :S. Only difference is you declared it as a type instead of passing it directly as a parameter. You don't "NEED" to create any typedef for the function.
Its the same as the answers I posted previously and on this thread: http://villavu.com/forum/showthread.php?t=93566