Results 1 to 12 of 12

Thread: If Else not working for me.

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

    Default If Else not working for me.

    My 'if else' is not working on my script for some reaosn. Not sure why. If I take it out the script works fine.

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

  2. #2
    Join Date
    Sep 2014
    Location
    Netherlands
    Posts
    264
    Mentioned
    11 Post(s)
    Quoted
    130 Post(s)

    Default

    Quote Originally Posted by nero_dante View Post
    My 'if else' is not working on my script for some reaosn. Not sure why. If I take it out the script works fine.

    Simba Code:
    procedure WalkLogBeam();
    var
      logBeam: Tbox;
    begin
        LogBeam := intTobox(286, 50, 293, 180);
        mouseBox(LogBeam, MOUSE_MOVE);
        if isMouseOverText('alk Log Bea') then
          fastClick(MOUSE_LEFT) //Here was the ';', remove this <------------
        else begin
          wait(500);
          writeLn('Can not find Looking again');
          terminateScript();
        end;
        WriteLn('Walking over LogBeam');
        wait(gaussRangeInt(5600,5800));
    Remove the ';'. I believe it should work then.

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

    Default

    Quote Originally Posted by SlipperyPickle View Post
    Remove the ';'. I believe it should work then.
    I tried that lol, still gives this error

    'Error: Found unexpected token "else", expected "End" at line 37
    Compiling failed.'

  4. #4
    Join Date
    Sep 2014
    Location
    Netherlands
    Posts
    264
    Mentioned
    11 Post(s)
    Quoted
    130 Post(s)

    Default

    Quote Originally Posted by nero_dante View Post
    I tried that lol, still gives this error

    'Error: Found unexpected token "else", expected "End" at line 37
    Compiling failed.'
    Simba Code:
    procedure WalkLogBeam();
    var
      logBeam: Tbox;
    begin
        LogBeam := intTobox(286, 50, 293, 180);
        mouseBox(LogBeam, MOUSE_MOVE);
        if isMouseOverText(['alk Log Bea']) then //<--- Add the '[]', because it needs an array.
          fastClick(MOUSE_LEFT) //Here was the ';', remove this <------------
        else begin
          wait(500);
          writeLn('Can not find Looking again');
          terminateScript();
        end;
        WriteLn('Walking over LogBeam');
        wait(gaussRangeInt(5600,5800));
        end;

    If you change the above, it should work.

  5. #5
    Join Date
    Dec 2010
    Posts
    483
    Mentioned
    30 Post(s)
    Quoted
    328 Post(s)

    Default

    The better option is to enclose any condition statements that will resolve to an else inside a begin/end.

    IE:

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

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

    Default

    Yeah I added in the '[]' and it runs the script, but it doesn't seem to find the mouse over text that I wrote. This is the error I'm getting now.

    '-- isMouseOverText()
    ---- Current mouse-over text: "Walk Log beam"
    ---- Current mouse-over text: "Walk Log beam"
    ---- Current mouse-over text: "Walk Log beam"
    ---- Current mouse-over text: "Walk Log beam"
    ---- Current mouse-over text: "Walk Log beam"
    ---- Current mouse-over text: "Walk Log beam"
    ---- Current mouse-over text: "Walk Log beam"
    ---- Current mouse-over text: "Walk Log beam"
    -- isMouseOverText(): False
    Can not find Looking again
    -- Succesfully freed SMART[22200]
    Successfully executed.'

  7. #7
    Join Date
    Sep 2014
    Location
    Netherlands
    Posts
    264
    Mentioned
    11 Post(s)
    Quoted
    130 Post(s)

    Default

    You have Bea in capital. But it's beam (in lowercase).

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

    Default

    Quote Originally Posted by SlipperyPickle View Post
    You have Bea in capital. But it's beam (in lowercase).
    Damn lol, didn't know something like that would be affected. Thanks. sorry about that xD

  9. #9
    Join Date
    Sep 2012
    Location
    Netherlands
    Posts
    2,752
    Mentioned
    193 Post(s)
    Quoted
    1468 Post(s)

    Default

    Quote Originally Posted by the bank View Post
    The better option is to enclose any condition statements that will resolve to an else inside a begin/end.

    IE:

    Simba Code:
    procedure WalkLogBeam();
    var
      logBeam: Tbox;
    begin
        LogBeam := intTobox(286, 50, 293, 180);
        mouseBox(LogBeam, MOUSE_MOVE);
        if isMouseOverText(['alk Log Bea']) then
        begin
          fastClick(MOUSE_LEFT);
        end else
        begin
          wait(500);
          writeLn('Can not find Looking again');
          terminateScript();
        end;
        WriteLn('Walking over LogBeam');
        wait(gaussRangeInt(5600,5800));
    end;
    that looks ugly

  10. #10
    Join Date
    Dec 2010
    Posts
    483
    Mentioned
    30 Post(s)
    Quoted
    328 Post(s)

    Default

    Quote Originally Posted by hoodz View Post
    that looks ugly
    I disagree. Disregarding a semi-colon just so that it can *technically* execute is the ugly option in my mind. Pascal is the only native language where something like that would ever be acceptable, and its not "meant" to work, it just does because of lax restrictions.

  11. #11
    Join Date
    Sep 2012
    Location
    Netherlands
    Posts
    2,752
    Mentioned
    193 Post(s)
    Quoted
    1468 Post(s)

    Default

    Quote Originally Posted by the bank View Post
    I disagree. Disregarding a semi-colon just so that it can *technically* execute is the ugly option in my mind. Pascal is the only native language where something like that would ever be acceptable, and its not "meant" to work, it just does because of lax restrictions.
    its just unnecessary extra code imo

  12. #12
    Join Date
    Feb 2012
    Location
    UK
    Posts
    909
    Mentioned
    10 Post(s)
    Quoted
    191 Post(s)

    Default

    I think it looks better without the begin and end, but I like to use the begin and end just to make it a bit more consistent with any other if statements.
    I see it as being one less thing that you need to remember too.
    Solar from RiD.

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
  •