I take exception to this Exception! - HELP
I have some behavior with exceptions that I don't understand. I'm using a
TEdit box to input a number that has to be an integer. I wrote this
handler for the OnExit event:
procedure TFrm.EdtNExit(Sender: TObject);
begin
inherited;
try
N := StrToInt(EdtN.Text);
except
on EConvertError do
EdtN.Text := IntToStr(N); // if not int, reset to previous value
end;
end;
N is an integer that is set to 0 in the form's OnCreate event.
The problem is that when I input, say, 63.4 in the edit box, the program
halts with an EConvertError "Value is not an integer". The way I
understand it from reading all the Delphi books is that the "try...except"
block is supposed to handle and clear the exception, and execution should
continue.
What am I doing wrong here?
--
Dr. Kenneth W. DeLong | Phone 510-423-1506
Lawrence Livermore National Lab | Fax 510-423-1488
L-395, Livermore CA 94550 | delo...@llnl.gov
Asonde kuraseru nara, sore wa sore de iin ja nai!!
Check out the FROG Web page at http://www.ca.sandia.gov/ultrafrog
Personal Page http://ourworld.compuserve.com/homepages/ken_delong