Results 1 to 4 of 4

Thread: Calling a function in a function

  1. #1
    Join Date
    Dec 2011
    Posts
    195
    Mentioned
    2 Post(s)
    Quoted
    17 Post(s)

    Default [Solved] Calling a function in a function

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

    But what I want is the function WaitUntil to repeat executing
    Simba Code:
    FindColor(X, Y, 0, 0, 0, 0, 0)
    every time it checks the value of
    Simba Code:
    Something: Boolean
    at
    Simba Code:
    repeat until Something;
    so that it would function like:
    Simba Code:
    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.
    Last edited by Nexz; 12-09-2012 at 02:31 AM.
    --- NexzAuto ---
    --- Simplicity is the ultimate sophistication. - Leonardo Da Vinci ---

  2. #2
    Join Date
    Dec 2011
    Location
    New York, USA
    Posts
    1,242
    Mentioned
    12 Post(s)
    Quoted
    193 Post(s)

    Default

    Just use WaitFuncEx?

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

    Default

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

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

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

  4. #4
    Join Date
    Dec 2011
    Posts
    195
    Mentioned
    2 Post(s)
    Quoted
    17 Post(s)

    Default

    @ Nebula and Brandon
    That's exactly what I was looking for. Thanks!
    --- NexzAuto ---
    --- Simplicity is the ultimate sophistication. - Leonardo Da Vinci ---

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
  •