如何中止循环?
for i:=0 to 100 do
for j:=0 to 100 do
begin
if Image1.Canvas.Pixels[i,j]=RGB(100,100,100) then
begin
showmessage(IntToStr(i)+','+IntToStr(j));
end;
end;
这样一个循环语句,由于RGB值是100,100,100的有很多点,所以会不停的弹提示,我只想要找到第一个就行了,应该怎么写?谢谢!
[解决办法]
for i:=0 to 100 do
for j:=0 to 100 do
begin
if Image1.Canvas.Pixels[i,j]=RGB(100,100,100) then
begin
showmessage(IntToStr(i)+','+IntToStr(j));
exit;
end;
end;
[解决办法]
for i:=0 to 100 do
for j:=0 to 100 do
begin
if Image1.Canvas.Pixels[i,j]=RGB(100,100,100) then
begin
showmessage(IntToStr(i)+','+IntToStr(j));
exit; end;
end;
[解决办法]
exit;
也可以用
try
failly
end;
-------------------------
try
except
end;
[解决办法]
var
i,j: Integer;
label
_next;
begin
for i:=0 to 100 do
for j:=0 to 100 do
begin
if Image1.Canvas.Pixels[i,j]=RGB(100,100,100) then
begin
showmessage(IntToStr(i)+','+IntToStr(j));
goto _next
end;
end;
_next:
showmessage('next')
end;