Results 1 to 12 of 12

Thread: Not In Loop - Need Help TroubleShooting

  1. #1
    Join Date
    Jun 2007
    Posts
    88
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Not In Loop - Need Help TroubleShooting

    I'm getting a error:

    Line 99: [Error] (12366:20): Not in a loop in script C:\Documents and Settings\...\My SRL Fletcher1.scar
    Here is what I've got, What I'm trying to do is run OpenBankQuiet and if that fails I want it to run OpenBankFast. I also have the PIN thrown in there too. I might be way off base but I think what I have is close.

    SCAR Code:
    Procedure Dbank;
    begin
      if(not(LoggedIn))then Exit;
      if(not(BankScreen))then
      begin
        OpenBankQuiet(Loc);
        Wait(2000 + Random(2000));
        if(BankScreen)then break;
        if(PinScreen)then (InPin(PinNumber));
        if(not(BankScreen))or(not(PinScreen))then
        begin
          OpenBankFast(Loc);
          Wait(2000 + Random(2000));
          if(BankScreen)then break;
          if(PinScreen)then (InPin(PinNumber));
          if(not(BankScreen))or(not(PinScreen))then
            Writeln('Failed to open bank.  Logging Out.');
            wait(until not(Loggedin));
    end;

    Line 99 is the first line that says " if(BankScreen)then break;"

  2. #2
    Join Date
    May 2006
    Posts
    1,230
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    SCAR Code:
    Procedure Dbank;
    begin
      if(not(LoggedIn))then Exit;
      if(not(BankScreen))then
      begin
        OpenBankQuiet(Loc);
        Wait(2000 + Random(2000));
        if(BankScreen)then break;
        if(PinScreen)then (InPin(PinNumber));
        if(not(BankScreen))or(not(PinScreen))then
        begin
          OpenBankFast(Loc);
          Wait(2000 + Random(2000));
          if(BankScreen)then break;
          if(PinScreen)then (InPin(PinNumber));
          if(not(BankScreen))or(not(PinScreen))then
          begin
            Writeln('Failed to open bank.  Logging Out.');
            while Loggedin do  wait(1000);
           end;
         end;
      end;
    end;

    never tested it, but it was because you had until_ and you didn't have a repeat, plus you didn't use it right..

    SCAR Code:
    repeat
      Wait(1000);
    until not Loggedin

  3. #3
    Join Date
    Sep 2006
    Location
    New Jersey, USA
    Posts
    5,347
    Mentioned
    1 Post(s)
    Quoted
    3 Post(s)

    Default

    Every begin has an end
    Every until has a repeat

    Only one of your begins has an end, and your until doesn't have a repeat.

    SCAR Code:
    repeat
      wait(100);
    until(not(loggedin))

    SCAR Code:
    if(x = y)then
    begin
      DoSomething;
      DoAnotherThing;
    end;

    SCAR Code:
    while (x <> y) do
    begin
      DoSomething;
      DoAnotherThing;
    end;

    EDIT: Beaten by 9 minutes! Same repeat example, too...
    Interested in C# and Electrical Engineering? This might interest you.

  4. #4
    Join Date
    Jun 2007
    Posts
    88
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Thanks again I'd be lost trying to learn this on my own.

    EDIT: OK still getting the same error on the same line. Changed script to following:

    SCAR Code:
    Procedure Dbank;
    begin
      if(not(LoggedIn))then Exit;
      if(not(BankScreen))then
      begin
        OpenBankQuiet(Loc);
        Wait(2000 + Random(2000));
        if(BankScreen)then break;
        if(PinScreen)then (InPin(PinNumber));
        if(not(BankScreen))or(not(PinScreen))then
        begin
          OpenBankFast(Loc);
          Wait(2000 + Random(2000));
          if(BankScreen)then break;
          if(PinScreen)then (InPin(PinNumber));
          if(not(BankScreen))or(not(PinScreen))then
          begin
            Writeln('Failed to open bank.  Logging Out.');
            while Loggedin repeat wait(1000)
            until (not(Loggedin))
          end;
        end;
      end;
    end;

  5. #5
    Join Date
    Jun 2007
    Posts
    88
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Ok edited my last comment so wanted to pop this back up for people to look at and I wanted to ask if I'm doing this right or is there an easier or better way to do?

  6. #6
    Join Date
    Apr 2007
    Location
    UK
    Posts
    2,295
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    SCAR Code:
    if(BankScreen)then break;

    Break can only be used if you are in a loop. You would need to do something along the lines of..

    SCAR Code:
    repeat
            Wait(2000 + Random(2000));
            if(BankScreen)then break;
          until(false)

    As you can see this is repeating the wait 2 seconds + random of 2 seconds, if it finds the bankscreen then it will break out of the loop.

    Rogeruk's Al-Kharid Tanner V1.1 [Released]
    Rogeruk's Barbarian Crafter [Coming Soon]
    Rogeruk's Guild Fisher [Coming Soon]
    !! - Taking Requests - !!

  7. #7
    Join Date
    Sep 2006
    Location
    New Jersey, USA
    Posts
    5,347
    Mentioned
    1 Post(s)
    Quoted
    3 Post(s)

    Default

    You're still missing a repeat.

    Every until needs a repeat.

    EDIT: *sigh*
    Interested in C# and Electrical Engineering? This might interest you.

  8. #8
    Join Date
    Oct 2006
    Location
    Ontario,Canada
    Posts
    1,718
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    SCAR Code:
    Procedure Dbank;
    begin
      if(not(LoggedIn))then Exit;
      if(not(BankScreen))then
      begin
        OpenBankQuiet(Loc);
        Wait(2000 + Random(2000));
        if(BankScreen)then exit; //CHANGE TO EXIT
        if(PinScreen)then (InPin(PinNumber));
        if(not(BankScreen))or(not(PinScreen))then
        begin
          OpenBankFast(Loc);
          Wait(2000 + Random(2000));
          if(BankScreen)then exit; //CHANGE TO EXIT
          if(PinScreen)then (InPin(PinNumber));
          if(not(BankScreen))or(not(PinScreen))then
          begin
            Writeln('Failed to open bank.  Logging Out.');
            repeat
               wait(1000)
            until (not(Loggedin))    
          end;
        end;
      end;
    end;

  9. #9
    Join Date
    Jun 2007
    Posts
    88
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Smartzkid View Post
    You're still missing a repeat.

    Every until needs a repeat.

    EDIT: *sigh*
    Is the *sigh* because you saw the repeat or because I was gone for too long. Doesn't this qualify?

    SCAR Code:
    while Loggedin repeat wait(1000)
         until (not(Loggedin))

    I added this into the last 2 lines before all the "ends".Or did I screw up some ordering?

    ------------------------------

    Quote Originally Posted by Rogeruk
    Break can only be used if you are in a loop. You would need to do something along the lines of..

    SCAR Code:
    repeat
            Wait(2000 + Random(2000));
            if(BankScreen)then break;
          until(false)


    As you can see this is repeating the wait 2 seconds + random of 2 seconds, if it finds the bankscreen then it will break out of the loop.
    I'm stuck on my Laptop now and my script is on the family desktop, I'll try it this way tomorrow. I think I'm just having a hard time wrapping my head around just what constitutes a "loop"

  10. #10
    Join Date
    Oct 2006
    Location
    Ontario,Canada
    Posts
    1,718
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    i just posted what should work.

    i dont see why you do
    while logged in repeat
    it should just be
    SCAR Code:
    repeat
    wait(100)
    antirandomthing
    until (not(loggedin)

  11. #11
    Join Date
    Jun 2007
    Posts
    88
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    XcanadamanX

    I like the way your repeat until loggedout looks I'm going to go with that I think that is where i was trying to get too.

    As far as the "exit" thats an easy enough change to make. What exactly is the difference between "break" and "exit" though?

  12. #12
    Join Date
    Oct 2006
    Location
    Ontario,Canada
    Posts
    1,718
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    break exits a loop while exit exits the whole procedure

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Ok, first script in a while - troubleshooting?
    By Sandstorm in forum OSR Help
    Replies: 3
    Last Post: 10-16-2008, 02:22 AM
  2. need for to do loop help
    By Raskolnikov in forum OSR Help
    Replies: 6
    Last Post: 07-02-2008, 03:21 AM
  3. Need help with Loop
    By Brenth in forum OSR Help
    Replies: 2
    Last Post: 12-31-2007, 05:35 PM
  4. For loop
    By rogeruk in forum OSR Help
    Replies: 8
    Last Post: 10-24-2007, 12:07 AM
  5. loop
    By macromacro123 in forum OSR Help
    Replies: 4
    Last Post: 03-18-2007, 07:50 PM

Posting Permissions

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