SRL Archive - General

MainLoop question


Zeta Matt

2013-02-10 16:59:08

begin
SetupSRL
ClearDebug;
if findcolortolerance(x, y, 65535, 745, 765, 817, 855, 4) or findcolortolerance(x, y, 65280, 745, 765, 817, 855, 4) then
begin
Playsound('c:\simba\alarm');
writeln('Your private chat is on, turn it off! ' + TheTime);
wait(2000);
StopSound;
end;
repeat
Detection;
until(r = 10);
end.

It's a unnecessery question, but I'd like to know why this MainLoop works if I write "Detection" without the ";"? like this:

begin
SetupSRL
ClearDebug;
if findcolortolerance(x, y, 65535, 745, 765, 817, 855, 4) or findcolortolerance(x, y, 65280, 745, 765, 817, 855, 4) then
begin
Playsound('c:\simba\alarm');
writeln('Your private chat is on, turn it off! ' + TheTime);
wait(2000);
StopSound;
end;
repeat
Detection
until(r = 10);
end.

What would be the difference?

riwu

2013-02-10 19:40:24

Semicolon can be omitted in PS in some cases w/o causing compilation error, but you should always add it at the end of statement for readability/prevent compilation error in most cases.

Awkwardsaw

2013-02-10 19:53:24

to answer your question, it's because the code can also be written like this:

 repeat dosomething until false; 

although what riwu said. It's best to do it the long ways for readability, as well as creating good habits.