Deiphi编译优化导致的死循环
2006-02-04 14:17:58 来源:WEB开发网核心提示: 请看下面这段代码:PRocedure TForm1.Button1Click(Sender: TObject);var strColor: string; i, R, G, B, p: integer; strlist: TStringList;begin strColor := medt.Text +
请看下面这段代码:
PRocedure TForm1.Button1Click(Sender: TObject);
var
strColor: string;
i, R, G, B, p: integer;
strlist: TStringList;
begin
strColor := medt.Text + '-';
strlist := TStringList.Create;
try
for R := 0 to 2 do //把变量R改为i正常
begin
//showmessage(inttostr(r)); 加上这句也正常了 循环体内读过R 值
p := pos('-', strColor);
strlist.Add(copy(strColor, 0, p-1));
delete(strColor, 1, p);
end;
R := strToint(strlist[0]);
G := strToint(strlist[1]);
B := strToint(strlist[2]);
finally
strlist.Free;
end;
Self.Color := TColor (RGB (R, G, B));
edtColor.Text := '$' + IntToHex (TColor (RGB (R, G, B)), 8);
edtColor.SetFocus;
end;
赞助商链接