From: svenlind@inet.uni-c.dk (Sven Lindhardt)
Subject: [delphi] Re: [Delphi] Some problems with new components
Date: Sat, 17 Jun 1995 16:30:10 +0200

I will answer the question myself. You can of course use floats in components.
But there is a problem. I have found out that, when in design mode, the float 
exceptions *ARE NOT ACTIVE*. That means that you should return to the 
good old ways and check for validity before operations that can fail.

Consider the following snippet.

constructor TAspectImage.Create(AOwner: TComponent);
var
  cx : double;
begin
  inherited Create(AOwner);
  .
  .
  .
  cx := 0;
  try
    cx := 100/cx;
  except on Exception do (* Nothing *)
  end;
end;

When the component is dropped on the form, then Delphi crashes, in spite
of the try..except block. (A rather drastic reaction I would say)
Changing the type of cx to integer (and "/" to div) then everything is ok.

Conclusion: Stick to the old ways of testing, when you are using floats. At
least in those parts that also are used during design time. This includes

constructors
paint methods
functions/procedures to the properties.
Probably the destructor too.

Sven Lindhardt

Email: svenlind@inet.uni-c.dk
