SRL Archive - General

Until True;


The Un-Named

2006-06-09 19:58:46

I've always wonderd what will happen when you change Until False; to true, well today I found out!

begin
repeat
writeln('lol');
until True;
end.

I think it only dose it 1 time because scar reads it like this:

repeat, ok
*says lol*
ok the loop has ended

Doubt you could use it for much but meh. ;)

Also, if you do for i := 0 to i do blah; it repeats forever, I think because scar reads it like this:

i is 0 and we want to repeat until i(or 0), but we haven't repeated yet so lets repeat (repeats), but we haven't repeated for 1 to 1

driger1592

2006-06-09 20:05:44

You've got the basic thinking down ;)

For the repeat..until(true), repeat..until's keep repeating until the until condition returns as true. Since you've set it to true, it's true. You may say that what I'm saying isn't exactly right because if you have a loop that waits until(function=false), it's not waiting until it's false. Actually, what I'm saying is true because it is waiting for the Condition to be true ;)

Your for..to..do loop thinking is basically right on :p

Jagex_Fagex

2006-06-09 20:29:18

From: driger1592
You've got the basic thinking down ;)

For the repeat..until(true), repeat..until's keep repeating until the until condition returns as true. Since you've set it to true, it's true. You may say that what I'm saying isn't exactly right because if you have a loop that waits until(function=false), it's not waiting until it's false. Actually, what I'm saying is true because it is waiting for the Condition to be true ;)

Your for..to..do loop thinking is basically right on :p



eh :confused: your just as bad as ben :rolleyes:

Cruel

2006-06-09 20:45:45

LAWL… you shouldn't ever use "until true;"… useless lol.
And you shouldn't use "for i:= 0 to i do" either… bad practice. Not to mention, in some languages, this won't repeat forever, but instead just once. But in SCAR I believe it will forever.

Avaphi

2006-06-09 21:31:00

Everyone, Could you use it like… You search for a color, and raise the tolerace by 1 until it finds it(True)??? Because if you could…that would be SUPERB.

driger1592

2006-06-10 00:14:20

I think The Un-Named realized that, but rather wanted to explain his thinking on why things happen this way in SCAR ;)

inferno

2006-06-10 04:58:23

From: db_cheater
Everyone, Could you use it like… You search for a color, and raise the tolerace by 1 until it finds it(True)??? Because if you could…that would be SUPERB.


You could just use:
[PHP]Function FindColRaiseTol(X, Y, Colour, X1, Y1, X2, Y2, MaxTol : Integer) : Boolean;
Var
Tol : Integer;
Begin
Result := False;
Repeat
If(FindColorSpiralTolerance(X, Y, Colour, X1, Y1, X2, Y2, Tol))Then
Result := True;
Wait(50 + Random(50));
Tol := Tol+1;
Until(Result)Or(Tol >= MaxTol);
End;

Begin
Repeat
Bla;
Until(FindColRaiseTol(X, Y, Colour, X1, Y1, X2, Y2, MaxTol));
End.[/PHP]

Cruel

2006-06-10 17:04:05

Yeah, that's pretty much it.
Although this would probably be better:

Function FindColRaiseTol(var X,Y:Integer; Colour,X1,Y1,X2,Y2,MaxTol :Integer) :Boolean; 
Var
Tol : Integer;
Begin
Repeat
If FindColorSpiralTolerance(X, Y, Colour, X1, Y1, X2, Y2, Tol) then exit;
Wait(50 + Random(50));
Tol := Tol+1;
Until Tol >= MaxTol;
Result:= False;
End;

Begin
if FindColRaiseTol(X, Y, Colour, X1, Y1, X2, Y2, MaxTol) then MoveMouse(X,Y);
End.

To return the X/Y variables.