Results 1 to 8 of 8

Thread: Repeat until a variable is anything OTHER than 'x'

  1. #1
    Join Date
    Aug 2010
    Posts
    122
    Mentioned
    0 Post(s)
    Quoted
    7 Post(s)

    Default Repeat until a variable is anything OTHER than 'x'

    Can someone show me an example of this?

    I basically have a fail safe on a private script that will repeat so long as a variable is "x" ... and I want to have a repeat until the variable is not X.

    I keep getting syntax errors... I tried


    repeat

    until not variable


    repeat

    until variable is not...


    Please an example...thank you in advance.


    Like this:
    Code:
    Procedure Takeoverworld;
    begin;
     repeat
      if Skyblue= 'True' then wait(5000+random(500));
     until Skyblue is not = 'True';
    Last edited by Mister Snow; 07-20-2012 at 02:43 AM.

  2. #2
    Join Date
    Apr 2012
    Location
    Australia
    Posts
    1,252
    Mentioned
    1 Post(s)
    Quoted
    22 Post(s)

    Default

    Simba Code:
    procedure Takeoverworld;
    begin;
     repeat
      if Skyblue := 'True' then
       wait(5000+random(500));
     until Skyblue <> 'True';
    end;

    That there 'should' work. What exactly are you trying to do? I assume this is not RS-related?

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

    Default

    Like this?

    Simba Code:
    While not(Var = x) do
      wait(50);

  4. #4
    Join Date
    Mar 2007
    Location
    USA
    Posts
    1,433
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    For your original logic to work (using boolean) here is an example.
    Simba Code:
    program new;
    var
    x: Boolean;// x declared as a Boolean for this to work
    i: Integer;
    begin
    x:=true;
    repeat
      Wait(100);
      Inc(i);
      Writeln('waiting: ' + IntToStr(i));
      if (i > 100) then
        x:= false;//set x false to break the loop.
    until not (x); //For it to just be until not 'x', 'x' has to be a boolean (true or false)
    end.

    PM me if you need anymore help.
    Last edited by Silent; 07-20-2012 at 07:41 AM.
    I'm Silent SPY
    Secret project: 0%
    Need help? Send me a PM

  5. #5
    Join Date
    Feb 2012
    Location
    Somewhere, over the rainbow...
    Posts
    2,272
    Mentioned
    3 Post(s)
    Quoted
    45 Post(s)

    Default

    Imo, Nebula's suggestion of using the while..do loop is probably the best way to go.

  6. #6
    Join Date
    Oct 2011
    Location
    UK
    Posts
    1,322
    Mentioned
    2 Post(s)
    Quoted
    1 Post(s)

    Default

    Quote Originally Posted by p1ng View Post
    Simba Code:
    procedure Takeoverworld;
    begin;
     repeat
      if Skyblue = 'True' then //No Colon
       wait(5000+random(500));
     until Skyblue <> 'True';
    end;
    Slight correction

  7. #7
    Join Date
    Aug 2010
    Posts
    122
    Mentioned
    0 Post(s)
    Quoted
    7 Post(s)

    Default

    Wow everyone, thanks a lot for so much help... this place is so nice.


    Quote Originally Posted by p1ng View Post
    Simba Code:
    procedure Takeoverworld;
    begin;
     repeat
      if Skyblue := 'True' then
       wait(5000+random(500));
     until Skyblue <> 'True';
    end;

    That there 'should' work. What exactly are you trying to do? I assume this is not RS-related?
    Turns out this did the trick... I didn't think <> would work since it's not an integer... but it sure did.

    ... and I totally forgot about "While Do" ... that should help me out a lot with these situations.

    It's probably the case that While Do is more proper for the situation, but both work... and you were just giving me what I asked for :P

    Thanks again for all the great help Villavu!

  8. #8
    Join Date
    Dec 2006
    Location
    Sydney, New South Wales, Australia
    Posts
    4,603
    Mentioned
    15 Post(s)
    Quoted
    42 Post(s)

    Default

    <> stands for "does not equal"
    The following are equivalent:
    • if(not(something =x )) then.
    • if(something <> x) then




    The not keyword simply inverts what is inside of the brackets.
    You may contact me with any concerns you have.
    Are you a victim of harassment? Please notify me or any other staff member.

    | SRL Community Rules | SRL Live Help & Chat | Setting up Simba | F.A.Q's |

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
  •