SRL Archive - OSR Help

Repeat until a variable is anything OTHER than 'x'


Mister Snow

2012-07-19 22:37:48

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:

Procedure Takeoverworld;
begin;
repeat
if Skyblue= 'True' then wait(5000+random(500));
until Skyblue is not = 'True';


P1ng

2012-07-19 22:49:12

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?

Nebula

2012-07-20 01:18:10

Like this?


While not(Var = x) do
wait(50);

Silent

2012-07-20 03:39:36

For your original logic to work (using boolean) here is an example.
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. :)

Abu

2012-07-20 07:01:26

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

putonajonny

2012-07-20 07:06:16

From: p1ng
procedure Takeoverworld;
begin;
repeat
if Skyblue = 'True' then //No Colon
wait(5000+random(500));
until Skyblue <> 'True';
end;


Slight correction

Mister Snow

2012-07-20 11:40:02

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


From: p1ng
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!

Daniel

2012-07-20 21:13:00

<> 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.