請問break為何無法跳出這個迴圈 ?? |
尚未結案
|
tab0922
一般會員 發表:4 回覆:3 積分:1 註冊:2004-10-10 發送簡訊給我 |
[code]
while not(flag) do
begin
ttt:
mytime:=timegettime;
while not(flag1)do
begin
if timegettime-mytime>=1 then
BEGIN
X:=X 1;
label3.Caption :=inttostr(x);
break;
end
else
begin
end;
end;
end; 請問一下,我想利用這段程式來達到每1ms做if判斷式中的程式~~
timegettime是以毫秒為單位~~
可是每次程式都會當掉,我發覺似乎是break的問題~~
能否請各位高手幫我看看,哪裡出問題了~~ 謝謝 ^^
|
Fishman
尊榮會員 發表:120 回覆:1949 積分:2163 註冊:2006-10-28 發送簡訊給我 |
Hi tab0922, 將 break 改為 exit 試試,因為 break 只會跳出目前迴圈(while not(flag1) do)而已,而 exit 則是: Exits from the current procedure. Unit System
while not(flag) do begin // ttt: mytime:=timegettime; while not(flag1) do begin if timegettime-mytime>=1 then BEGIN X:=X 1; label3.Caption :=inttostr(x); Exit; end else begin end; end; end;發表人 -
------
Fishman |
tab0922
一般會員 發表:4 回覆:3 積分:1 註冊:2004-10-10 發送簡訊給我 |
|
Fishman
尊榮會員 發表:120 回覆:1949 積分:2163 註冊:2006-10-28 發送簡訊給我 |
Hi tab0922,
while not(flag) do begin // ttt: mytime:=timegettime; while not(flag1) do begin if timegettime-mytime>=1 then BEGIN X:=X 1; label3.Caption :=inttostr(x); Flag1 := true; Break; end else begin end; end; // Add some program here to control flag end;---------------------------------- 小弟才疏學淺,若有謬誤尚請不吝指教 ----------------------------------
------
Fishman |
Miles
尊榮會員 發表:27 回覆:662 積分:622 註冊:2002-07-12 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |