Results 1 to 20 of 20

Thread: Waitfunc inside other function

  1. #1
    Join Date
    Oct 2011
    Posts
    805
    Mentioned
    21 Post(s)
    Quoted
    152 Post(s)

    Arrow Waitfunc inside other function

    How to put WaitFunc inside other function?

    I was trying...

    Simba Code:
    program new;
    {$DEFINE SRL5}
    {$i srl/srl.simba}

    function Test (Func: function : boolean) : Boolean ;
    begin
      if (WaitFunc(@func,100,5000)) then
       writeln ('something');
    end;

    begin
    end.

    Code:
    [Error] (8:17): Unknown identifier 'func' at line 7
    and

    Simba Code:
    program new;
    {$DEFINE SRL5}
    {$i srl/srl.simba}

    function Test (Func: function) : Boolean ;
    begin
      if (WaitFunc(@func,100,5000)) then
       writeln ('something');
    end;

    begin
    end.
    Code:
    [Error] (6:30): colon (':') expected at line 5
    and

    Simba Code:
    program new;
    {$DEFINE SRL5}
    {$i srl/srl.simba}

    function Test (Func: function : boolean) : Boolean ;
    begin
      if (WaitFunc(func,100,5000)) then
       writeln ('something');
    end;

    begin
    end.
    Code:
    [Error] (8:32): Type mismatch at line 7
    I have really no idea. Anyone could help?

  2. #2
    Join Date
    Sep 2010
    Location
    Azeroth
    Posts
    395
    Mentioned
    0 Post(s)
    Quoted
    17 Post(s)

    Default

    Simba Code:
    program new;
    {$i srl/srl.scar}



    function CallSelf: Boolean;
    begin
    if CallSelf then
    result:= True;
    end;


    function Yeah: string;
    begin
    if callSelf then
    result:= 'Yeah';
    end;




    begin
    writeln(Yeah);
    end.



    http://villavu.com/forum/showthread.php?t=59061


    http://villavu.com/forum/showthread.php?t=54716


    http://villavu.com/forum/showthread.php?t=47134

  3. #3
    Join Date
    Oct 2011
    Posts
    805
    Mentioned
    21 Post(s)
    Quoted
    152 Post(s)

    Default

    Hmm...I don't understand. Could you make example with WaitFunc?

    thanks for link ,but i can't find answer there.



    @ edit

    At last i can do something like:
    Simba Code:
    program new;
    {$DEFINE SRL5}
    {$i srl/srl.simba}

    function Test (Func: function : boolean) : Boolean ;
    var
      T, WaitPerLoop, MaxTime: Integer;
      Result_WF : boolean;
    begin

      /////////WaitFunc////////////////
      T := GetSystemTime + MaxTime;
      while (GetSystemTime < T) do
      begin
        if (Func()) then
        begin
          Result_WF := True;
          Exit;
        end;
        Wait(WaitPerLoop);
      end;
      /////////end of WaitFunc/////////

      if (Result_WF) then
       writeln ('something');
    end;

    But it's ugly
    Last edited by bg5; 01-04-2012 at 10:12 AM.

  4. #4
    Join Date
    Sep 2010
    Location
    Azeroth
    Posts
    395
    Mentioned
    0 Post(s)
    Quoted
    17 Post(s)

    Default

    you should really try and follow the proper structure of a function



    Simba Code:
    {$i srl\srl.scar}



    function Foundcolor: Boolean;
    var
    x,y:integer;
     begin
     if
      findcolor(x, y, 111111, 1,1,520,340 ) then
    begin
      result:=true
      end;
       end;



    begin
     repeat
       Waitnone;
    //until Wait until we found the color...
      until(WaitFunc(@FoundColor, 8000+ Random(15), 9000));
    end.




    make your own function

    Simba Code:
    //this type of function is called a boolean, meaning it can either be true or false
    Function NameOfFunction: Boolean;
    Begin
    If findColor(x, y, 111111, 1,1,520,340)then
    Begin
    Result:=True
    End;


    //when using a function in your script you simply put the name

    repeat
    writeln('waiting')
    //until the color is found
    until(NameOfFunction)

    have you any programming experience?
    it may be tough but try reading any book on programming
    try Java...
    youll eventually will be more familiar...
    Personally I like Python because it has PyGame =)
    Last edited by wantonman; 01-04-2012 at 10:02 PM.

  5. #5
    Join Date
    Oct 2008
    Location
    C:\Simba\Includes\
    Posts
    7,566
    Mentioned
    19 Post(s)
    Quoted
    180 Post(s)

    Default

    wantonman, your structure, or "standards" are horrible. Beginner had them right.
    Away for awhile, life is keeping me busy. | Want to get my attention in a thread? @Kyle Undefined; me.
    { MSI Phoenix || SRL Stats Sigs || Paste || Scripts || Quotes || Graphics }

    When posting a bug, please post debug! Help us, help you!

    I would love to change the world, but they won't give me the source code. || To be the best, you've got to beat the rest. || Logic never changes, just the syntax.
    If you PM me with a stupid question or one listed in FAQ, or about a script that is not mine, I will NOT respond.


    SRL is a Library of routines made by the SRL community written for the Program Simba. We produce Scripts for the game Runescape.


  6. #6
    Join Date
    Sep 2010
    Location
    Azeroth
    Posts
    395
    Mentioned
    0 Post(s)
    Quoted
    17 Post(s)

    Default

    okay even if i dont its still good to mention it..........

  7. #7
    Join Date
    Oct 2011
    Posts
    805
    Mentioned
    21 Post(s)
    Quoted
    152 Post(s)

    Default

    have you any programming experience?
    it may be tough but try reading any book on programming
    It's really strange you said that ,because you misunderstood my problem. I didn't ask about making basic function , my question was clear:
    How to put WaitFunc inside other function?
    And the code you showed me will do nothing, because callself is always false. I'm not going to be rude ,but if you really want to help somebody you should take more care about your answers ,and what's a point of question. I'm sure you didn't even compile this:

    Simba Code:
    program new;
    {$i srl/srl.scar}

    function CallSelf: Boolean;
    begin
    if CallSelf then      // so if False then True ? :)
    result:= True;
    end;

    function Yeah: string;
    begin
    if callSelf then       // if False...
    result:= 'Yeah';
    end;

    begin
    writeln(Yeah);      // write empty string and stuck script in infinity loop !
    end.

  8. #8
    Join Date
    Oct 2008
    Location
    C:\Simba\Includes\
    Posts
    7,566
    Mentioned
    19 Post(s)
    Quoted
    180 Post(s)

    Default

    You're basically trying to make a wrapper, why not just use "WaitFunc" where needed?
    Away for awhile, life is keeping me busy. | Want to get my attention in a thread? @Kyle Undefined; me.
    { MSI Phoenix || SRL Stats Sigs || Paste || Scripts || Quotes || Graphics }

    When posting a bug, please post debug! Help us, help you!

    I would love to change the world, but they won't give me the source code. || To be the best, you've got to beat the rest. || Logic never changes, just the syntax.
    If you PM me with a stupid question or one listed in FAQ, or about a script that is not mine, I will NOT respond.


    SRL is a Library of routines made by the SRL community written for the Program Simba. We produce Scripts for the game Runescape.


  9. #9
    Join Date
    Sep 2010
    Location
    Azeroth
    Posts
    395
    Mentioned
    0 Post(s)
    Quoted
    17 Post(s)

    Default

    i did put it inside another function and i gave you multiple examples

  10. #10
    Join Date
    Oct 2011
    Posts
    805
    Mentioned
    21 Post(s)
    Quoted
    152 Post(s)

    Default

    Quote Originally Posted by Kyle Undefined View Post
    You're basically trying to make a wrapper, why not just use "WaitFunc" where needed?
    I need to put WaitFunc inside more complicated function ,not only wrapper. My example script was only for testing :P

  11. #11
    Join Date
    Oct 2008
    Location
    C:\Simba\Includes\
    Posts
    7,566
    Mentioned
    19 Post(s)
    Quoted
    180 Post(s)

    Default

    Ah I see now, there's no way you can use WaitFunc there without having to make another function?
    Away for awhile, life is keeping me busy. | Want to get my attention in a thread? @Kyle Undefined; me.
    { MSI Phoenix || SRL Stats Sigs || Paste || Scripts || Quotes || Graphics }

    When posting a bug, please post debug! Help us, help you!

    I would love to change the world, but they won't give me the source code. || To be the best, you've got to beat the rest. || Logic never changes, just the syntax.
    If you PM me with a stupid question or one listed in FAQ, or about a script that is not mine, I will NOT respond.


    SRL is a Library of routines made by the SRL community written for the Program Simba. We produce Scripts for the game Runescape.


  12. #12
    Join Date
    Jan 2008
    Location
    10° north of Hell
    Posts
    2,035
    Mentioned
    65 Post(s)
    Quoted
    164 Post(s)

    Default

    Quote Originally Posted by beginner5 View Post
    How to put WaitFunc inside other function?

    I was trying...

    Simba Code:
    program new;
    {$DEFINE SRL5}
    {$i srl/srl.simba}

    function Test (Func: function : boolean) : Boolean ;
    begin
      if (WaitFunc(@func,100,5000)) then
       writeln ('something');
    end;

    begin
    end.

    Code:
    [Error] (8:17): Unknown identifier 'func' at line 7
    and

    Simba Code:
    program new;
    {$DEFINE SRL5}
    {$i srl/srl.simba}

    function Test (Func: function) : Boolean ;
    begin
      if (WaitFunc(@func,100,5000)) then
       writeln ('something');
    end;

    begin
    end.
    Code:
    [Error] (6:30): colon (':') expected at line 5
    and

    Simba Code:
    program new;
    {$DEFINE SRL5}
    {$i srl/srl.simba}

    function Test (Func: function : boolean) : Boolean ;
    begin
      if (WaitFunc(func,100,5000)) then
       writeln ('something');
    end;

    begin
    end.
    Code:
    [Error] (8:32): Type mismatch at line 7
    I have really no idea. Anyone could help?
    You can't, seems there is a bug in PascalScript preventing the passing of a function pointer more than once.

    Dg's Small Procedures | IRC Quotes
    Thank Wishlah for my nice new avatar!
    Quote Originally Posted by IRC
    [22:12:05] <Dgby714> Im agnostic
    [22:12:36] <Blumblebee> :O ...you can read minds

  13. #13
    Join Date
    Sep 2010
    Location
    Azeroth
    Posts
    395
    Mentioned
    0 Post(s)
    Quoted
    17 Post(s)

    Wink

    perhaps putting the @ symbol waitfunk(@funk... harhar just because you cant figure it out does not mean the entire pascal scripting language is dead!
    You can't, seems there is a bug in PascalScript preventing the passing of a function pointer more than once.



    This writes something
    Simba Code:
    program new;
    {$DEFINE SRL5}
    {$i srl/srl.simba}




    function Zero : Boolean ;
    begin
     MoveMouse ( 640 , 420 )
    end ;




    function One : Boolean ;
    begin
     if WaitFunc ( @ Zero , 100 , 5000 ) then
      Result := True ;
    end ;









    function Two : Boolean ;
    begin
     WaitFunc ( @ One , 100 , 10000 )
     writeln ( 'something' ) ;
    end ;





    procedure Proced ;
    Begin
     Two ;
     One ;
     Zero ;
    end ;


    begin
     proced ;
    end.
    Wait Function waits for a function to be true. So you said have it in a function? Sure why not? You can.

    It just equals the result of it, thats all. Either it will wait for the function to be true or false. Weather or not it still results it still would have completed the function, get me? Either way it still is going to be true.

    I dont know if that is what your asking.
    Last edited by wantonman; 01-05-2012 at 10:40 PM.

  14. #14
    Join Date
    Oct 2011
    Posts
    805
    Mentioned
    21 Post(s)
    Quoted
    152 Post(s)

    Default

    You can't, seems there is a bug in PascalScript preventing the passing of a function pointer more than once.
    That's bad news ,so I will have to integrate waitfunc with two superior funcions ,joining 3 in one It seems crazy.

    Is there no way to bypass this bug?



    @wantonman

    Simba Code:
    function One : Boolean ;
    begin
     if WaitFunc ( @ Zero , 100 , 5000 ) then
      Result := True ;
    end ;

    function Two : Boolean ;
    begin
     WaitFunc ( @ One , 100 , 10000 )
     writeln ( 'something' ) ;
    end ;

    Not Waitfunc inside Waitfunc ,but: put to WaitFunc @function given as argument to superior function like:

    Simba Code:
    function Two (Func : function : boolean) : Boolean ;
    begin
     WaitFunc ( @ Func , 100 , 10000 );
     writeln ( 'something' ) ;
    end ;

    begin
    Two(@One);
    end.
    Last edited by bg5; 01-05-2012 at 11:29 PM.

  15. #15
    Join Date
    Jan 2008
    Location
    10° north of Hell
    Posts
    2,035
    Mentioned
    65 Post(s)
    Quoted
    164 Post(s)

    Default

    Quote Originally Posted by beginner5 View Post
    That's bad news ,so I will have to integrate waitfunc with two superior funcions ,joining 3 in one It seems crazy.

    Is there no way to bypass this bug?
    Write your own WaitFunc? It's actually a really simple function.

    Dg's Small Procedures | IRC Quotes
    Thank Wishlah for my nice new avatar!
    Quote Originally Posted by IRC
    [22:12:05] <Dgby714> Im agnostic
    [22:12:36] <Blumblebee> :O ...you can read minds

  16. #16
    Join Date
    Oct 2011
    Posts
    805
    Mentioned
    21 Post(s)
    Quoted
    152 Post(s)

    Default

    Write your own WaitFunc? It's actually a really simple function.
    You mean function which does the same as WaitFunc? I really have no idea how to put function as argument to second function in other way then waitfunc does (func :function: boolen).

    for example:

    Simba Code:
    function WaitFunc2(Func : Boolean ; WaitPerLoop, MaxTime: Integer): Boolean;
    var
      T: Integer;
    begin
      T := GetSystemTime + MaxTime;
      while (GetSystemTime < T) do
      begin
        if (Func) then
        begin
          Result := True;
          Exit;
        end;
        Wait(WaitPerLoop);
      end;
    end;

    begin
    Waitfunc2(Checker,10,10000);
    end.

    not works ,because it execute Func only once. Maybe it's easy ,but not for me.

  17. #17
    Join Date
    Jan 2008
    Location
    10° north of Hell
    Posts
    2,035
    Mentioned
    65 Post(s)
    Quoted
    164 Post(s)

    Default

    Quote Originally Posted by beginner5 View Post
    You mean function which does the same as WaitFunc? I really have no idea how to put function as argument to second function in other way then waitfunc does (func :function: boolen).

    for example:

    Simba Code:
    function WaitFunc2(Func : Boolean ; WaitPerLoop, MaxTime: Integer): Boolean;
    var
      T: Integer;
    begin
      T := GetSystemTime + MaxTime;
      while (GetSystemTime < T) do
      begin
        if (Func) then
        begin
          Result := True;
          Exit;
        end;
        Wait(WaitPerLoop);
      end;
    end;

    begin
    Waitfunc2(Checker,10,10000);
    end.

    not works ,because it execute Func only once. Maybe it's easy ,but not for me.
    function WaitFunc2(Func : Boolean ; WaitPerLoop, MaxTime: Integer): Boolean;

    needs to be

    function WaitFunc2(Func: function: Boolean; WaitPerLoop, MaxTime: Integer): Boolean;

    and

    Waitfunc2(Checker,10,10000);

    needs to be

    Waitfunc2(@Checker,10,10000);

    Dg's Small Procedures | IRC Quotes
    Thank Wishlah for my nice new avatar!
    Quote Originally Posted by IRC
    [22:12:05] <Dgby714> Im agnostic
    [22:12:36] <Blumblebee> :O ...you can read minds

  18. #18
    Join Date
    Jan 2008
    Location
    10° north of Hell
    Posts
    2,035
    Mentioned
    65 Post(s)
    Quoted
    164 Post(s)

    Default

    Actually I just remembered, you may want something like this.

    http://villavu.com/forum/showpost.ph...15&postcount=9

    Dg's Small Procedures | IRC Quotes
    Thank Wishlah for my nice new avatar!
    Quote Originally Posted by IRC
    [22:12:05] <Dgby714> Im agnostic
    [22:12:36] <Blumblebee> :O ...you can read minds

  19. #19
    Join Date
    Oct 2011
    Posts
    805
    Mentioned
    21 Post(s)
    Quoted
    152 Post(s)

    Default

    Actually I just remembered, you may want something like this.

    http://villavu.com/forum/showpost.ph...15&postcount=9
    Wow ,your function is beast ,it really helped me with everything TYVM

    Why it's not in SRL?
    Last edited by bg5; 01-06-2012 at 01:17 AM.

  20. #20
    Join Date
    Jan 2008
    Location
    10° north of Hell
    Posts
    2,035
    Mentioned
    65 Post(s)
    Quoted
    164 Post(s)

    Default

    Quote Originally Posted by beginner5 View Post
    Wow ,your function is beast ,it really helped me with everything TYVM

    Why it's not in SRL?
    No one has added it yet? I don't use SRL so I didn't send it in...

    Dg's Small Procedures | IRC Quotes
    Thank Wishlah for my nice new avatar!
    Quote Originally Posted by IRC
    [22:12:05] <Dgby714> Im agnostic
    [22:12:36] <Blumblebee> :O ...you can read minds

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
  •