In article <807a17$cn...@news.tudelft.nl>,
"D. Nakken" <d.nak...@student.tudelft.nl> wrote:
Quote
> Hello,
> I am trying to make a program to calculate some thing, therefore I
need to
> read values from edit-boxes, and then calculate with it.
> so I did this.
> L:=StrToFloat(form1.LEdit.Text);
> This workes.
> But now I want to give a error message when someone puts text in this
> edit-box instead of a number, because now my program crashes when it
wants
> to read the edit-box.
> I think it should look something like this:
> Try
> ........
> except
> .........
> end;
> but if I put "L:=StrToFloat(form1.LEdit.Text);'' in the Try part then
the
> program still crashes.
> Do you have an answer?
> Thanks! Douwe
It is not that the program "crashes", it is only doing exactly what I
would expect. If you want the program to execute the except clause
without going to the de{*word*81} when the exception occurs you will need to
turn off "break on exception" in the project settings. The system
however will then not break on ANY exceptions. There was a posting a
couple of weeks ago about how to turn "break on exception" "off" from
your code, but none of the answers were a neat solution, I was hoping to
see something like {BREAK_ON_EXCEPTION OFF} just like the directive
{WARNINGS OFF} but the IDE does not support this :-(. If you just step
to the next line, the de{*word*81} will execute your first line of code in
the except clause and you can continue to run or step as desired. If
you run your program from outside the IDE you will see that it will trap
the errors seamlessly, just as you would expect it to. I know it is
annoying, but even with try blocks you cannot seem to stop Delphi from
telling you about the error and THEN doing what error handling you have
written :-(
Trevor
Sent via Deja.com http://www.deja.com/
Before you buy.