HELP Exception handling doesn't work

Stefaan Lesage <> wrote:
> Now I also had to write a little function which could check if a certain
> String is a correct Date, so I programmed the folowing :

> Function IsDate (Datum : String) : Boolean;
> begin
>      Try
>           Result := True;
>           StrToDate(Datum);
>      Except
>           On EConvertError Do
>           begin
>                ShowMessage ('Not a valid date format ! ! !');
>                Result := False;
>           end;
>      End;
> end;

Design hint:
A function named IsDate shouldn't show a dialog to the user if not IsDate.

> For as far as I know, I don't see anything wrong with this (if something
> wrong, let me know).

Can't see anything wrong, but I would either remove the ShowMessage, or at
least rename the function.

- Show quoted text -

>      if IsDate(EditBestel_Datum.text) <> true then
>      Begin
>           ShowMessage ('De ingevoerde tekst is geen datum !');  {The text
> isn't a date)
>           EditBestel_Datum.Text := '';
>           EditBestel_Datum.Setfocus;
>      End;    

> This should be ok, and the function should normally handle the exeption
> when the entered text isn't a date, but again everything fails.  When the
> parameter Datum, which is passed to the function, contains something else
> than a date, the program terminates with the folowing error message :

>      Project Fotek.EXE raised an exception class EConvertError with the
> message 'Tekst'
>      is not a valid date and time.  Process stopped, use step or run to
> continue.

> The program then ends.

Sounds like you're running your program from inside Delphi, and with 'Break
on Exception' set to true.
Either disable 'Break on exception', or run it outside of the IDE to not
get this "extra" notification.

If you press 'run' to continue, you should see your exception being handled
according to your plan.
(But of course you'll see both an english ShowMessage as well as one in
your native tongue)

BTW: Please don't do all this cross-posting, many persons have stopped
reading the news due to this.
(myself "somewhat" included.)