Subject Re: [IBO] Addition: TIB_ColumnNumeric.Get/SetAsInteger
Author Jason Wharton
I'll incorporate these suggestions right away.

Thanks!
Jason Wharton
CPS - Mesa AZ
http://www.ibobjects.com


----- Original Message -----
From: "Jeroen W. Pluimers" <jeroen.mailings@...>
To: <IBObjects@egroups.com>
Sent: Monday, December 04, 2000 4:56 AM
Subject: [IBO] Addition: TIB_ColumnNumeric.Get/SetAsInteger


> Jason,
>
>
> To make it easier (i.e. have less exceptions) I added the following two
> functions to TIB_ColumnNumberic:
>
> function GetAsInteger: integer; override; // ##jp: for SpinEdit
> procedure SetAsInteger( const NewValue: integer ); override; // ##jp:
for
> SpinEdit
>
> function TIB_ColumnNumeric.GetAsInteger: integer;
> begin
> {$IFDEF IBO_VCL40_OR_GREATER}
> Result := Trunc( Value );
> {$ELSE}
> Result := Trunc( AsExtended );
> {$ENDIF}
> end;
>
> procedure TIB_ColumnNumeric.SetAsInteger( const NewValue: integer);
> begin
> {$IFDEF IBO_VCL40_OR_GREATER}
> Value := NewValue;
> {$ELSE}
> AsExtended := NewValue;
> {$ENDIF}
> end;
>
> Especially on non-US regional settings that have a decimal separator other
> than a dot (.), using a SpinEdit with a Numeric column, you get many
> exceptions indicating the expected integer is not a number. Of course this
> is handled by the try/except block in TIB_Column.GetAsInteger, but
> exceptions are very CPU expensive (since they should be exceptionoal). The
> fix above will prevent these exceptions, and also optimize the AsInteger
(In
> GetAsInteger a Trunc is much faster than a FormatFloat/StrToInt
combination,
> similar performance increasment for the SetAsInteger).
>
> Jeroen W. Pluimers
> Consultant at All I M
> http://www.all-im.com