Results 1 to 4 of 4

Thread: Saving function argument of type function : boolean

  1. #1
    Join Date
    Oct 2011
    Posts
    422
    Mentioned
    15 Post(s)
    Quoted
    116 Post(s)

    Default Saving function argument of type function : boolean

    why does this throw a mismatch error? http://pastebin.com/My4Cxw87
    line 17

  2. #2
    Join Date
    Feb 2011
    Location
    The Future.
    Posts
    5,600
    Mentioned
    396 Post(s)
    Quoted
    1598 Post(s)

    Default

    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;
    Last edited by Brandon; 12-08-2012 at 04:30 PM.
    I am Ggzz..
    Hackintosher

  3. #3
    Join Date
    Oct 2011
    Posts
    422
    Mentioned
    15 Post(s)
    Quoted
    116 Post(s)

    Default

    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

  4. #4
    Join Date
    Feb 2011
    Location
    The Future.
    Posts
    5,600
    Mentioned
    396 Post(s)
    Quoted
    1598 Post(s)

    Default

    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
    Last edited by Brandon; 12-09-2012 at 03:46 AM.
    I am Ggzz..
    Hackintosher

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •