Results 1 to 5 of 5

Thread: How to repeat Procedure if something is not found

  1. #1
    Join Date
    Aug 2014
    Posts
    172
    Mentioned
    2 Post(s)
    Quoted
    77 Post(s)

    Default How to repeat Procedure if something is not found

    Thanks again all for the quik reply and support you guys give and I'm probably going to be bring out quite a few different posts to help me through my beginning scripting days. Hope its okay to all :P

    What I'm stuck on n ow, is finding out how to repeat a procedure if it fails. That's the code below. It hovers over the log beam and if it finds the text it clicks, but if it doesn't I want it to repeat the procedure, is there a way of doing that?

    Code:
    procedure WalkLogBeam();
    var
      logBeam: Tbox;
    begin
      LogBeam := intTobox(286, 50, 293, 180);
      mouseBox(LogBeam, MOUSE_MOVE);
      if isMouseOverText('alk log bea, log beam') then
      fastClick(MOUSE_LEFT)
      else begin
        writeLn('Can not find Looking again');
    
      WriteLn('Walking over LogBeam');
      wait(gaussRangeInt(5600,5800));
    end;

  2. #2
    Join Date
    Jan 2007
    Location
    East Coast, USA
    Posts
    138
    Mentioned
    0 Post(s)
    Quoted
    38 Post(s)

    Default

    If that were a function that returned true or false depending on it's success, you could then use:
    Simba Code:
    WaitFunc(@functionName, 100, 1000);
    It would repeat the function functionName for 1000 ms at an interval of 100 ms or until it returns true.

    And by obligation I must mention that using a TBox to locate the log could be better done with the help of color. But I'm sure you'll get to that later on.

  3. #3
    Join Date
    Jun 2014
    Location
    Lithuania
    Posts
    475
    Mentioned
    27 Post(s)
    Quoted
    200 Post(s)

    Default

    Quote Originally Posted by nero_dante View Post
    Thanks again all for the quik reply and support you guys give and I'm probably going to be bring out quite a few different posts to help me through my beginning scripting days. Hope its okay to all :P

    What I'm stuck on n ow, is finding out how to repeat a procedure if it fails. That's the code below. It hovers over the log beam and if it finds the text it clicks, but if it doesn't I want it to repeat the procedure, is there a way of doing that?

    Code:
    procedure WalkLogBeam();
    var
      logBeam: Tbox;
    begin
      LogBeam := intTobox(286, 50, 293, 180);
      mouseBox(LogBeam, MOUSE_MOVE);
      if isMouseOverText('alk log bea, log beam') then
      fastClick(MOUSE_LEFT)
      else begin
        writeLn('Can not find Looking again');
    
      WriteLn('Walking over LogBeam');
      wait(gaussRangeInt(5600,5800));
    end;

    Simba Code:
    program blahaalala;
    var t:ttimemarker;

    function WalkLogBeam():boolean;// <-function will return if succesfull or not;
    var
      logBeam: Tbox;
    begin
      result:=false;//<- declare result as false because you havent clicked it yet;
      LogBeam := intTobox(286, 50, 293, 180);
      mouseBox(LogBeam, MOUSE_MOVE);
      if isMouseOverText('alk log bea, log beam') then
        begin
         result:=didclick(true);// <- will give true if mouseclick is red color which means clicked
         WriteLn('Walking over LogBeam');
         wait(gaussRangeInt(5600,5800));
        end
        else writeLn('Can not find'); //<- otherwise if fails result stays at false;
    end;
    begin

    if not walklogbeam() then walklogbeam();// <- will repeat once if didnt clicked on beam
    //optional//\

    t.start();
    repeat
    wait(200);
    until walklogbeam() or t.gettime()>25000;// <- will repeat untill walks through beam, so need failsafe ttimemarker to stop doing infinity loop after 25 secs for example.

    //////////
    end;

    Edit: by the way started to write it as junior member, now member So you should pretty much apreciate it for that amount of time spended

  4. #4
    Join Date
    Aug 2014
    Posts
    172
    Mentioned
    2 Post(s)
    Quoted
    77 Post(s)

    Default

    Quote Originally Posted by cosmasjdz View Post
    Simba Code:
    program blahaalala;
    var t:ttimemarker;

    function WalkLogBeam():boolean;// <-function will return if succesfull or not;
    var
      logBeam: Tbox;
    begin
      result:=false;//<- declare result as false because you havent clicked it yet;
      LogBeam := intTobox(286, 50, 293, 180);
      mouseBox(LogBeam, MOUSE_MOVE);
      if isMouseOverText('alk log bea, log beam') then
        begin
         result:=didclick(true);// <- will give true if mouseclick is red color which means clicked
         WriteLn('Walking over LogBeam');
         wait(gaussRangeInt(5600,5800));
        end
        else writeLn('Can not find'); //<- otherwise if fails result stays at false;
    end;
    begin

    if not walklogbeam() then walklogbeam();// <- will repeat once if didnt clicked on beam
    //optional//\

    t.start();
    repeat
    wait(200);
    until walklogbeam() or t.gettime()>25000;// <- will repeat untill walks through beam, so need failsafe ttimemarker to stop doing infinity loop after 25 secs for example.

    //////////
    end;

    Edit: by the way started to write it as junior member, now member So you should pretty much apreciate it for that amount of time spended
    Oh so making it a function would allow it to work easier than as a procedure. Thanks for that ... also I didn't understand the last thing you wrote lol xD. However, I did appreciate all help that I get

  5. #5
    Join Date
    Aug 2014
    Posts
    172
    Mentioned
    2 Post(s)
    Quoted
    77 Post(s)

    Default

    Quote Originally Posted by fastler View Post
    If that were a function that returned true or false depending on it's success, you could then use:
    Simba Code:
    WaitFunc(@functionName, 100, 1000);
    It would repeat the function functionName for 1000 ms at an interval of 100 ms or until it returns true.

    And by obligation I must mention that using a TBox to locate the log could be better done with the help of color. But I'm sure you'll get to that later on.
    yeah I will be adding the help of colour later on

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
  •