Subject Re: [IBO] Still having problems with OnCalculateField
Author Stuart Hunt
--- In, Nando Dessena <nandod@d...> wrote:
> Helen et al,
> >>if you use AsString anywhere outside of the
> >>OnCalculateField event it trims the field fine.
> H> AsString reads a variant. Delphi doesn't have fixed length
character types.
> neither does it arbitrarily delete trailing spaces from strings or
> variants, for that matter. :-)
> I haven't tested, but I find it hard to believe that this sentence:
> >>if you use AsString anywhere outside of the
> >>OnCalculateField event it trims the field fine.
> holds true for char fields. If it does, then IBO is doing something
> wrong. I am curious about what Jason has to say about it.
> Ciao
> --
> Nando mailto:nandod@d...

maybe I'm not explaining myself very well here. the problem is that
we have FORENAME as a CHAR (15) and SURNAME as a CHAR (30). If we
store the following information in these 2 fields:


then have a TIB_Query that returns both these fields - i.e.

if you do:
('FORENAME').AsString+' '+IB_Query.FieldByName('SURNAME').AsString)
then it (correctly) returns:
"Stuart Hunt". i.e. it doesn't pad the fields out to their maximum
If, however, you add a calculated field to the
TIB_Query.CalculatedFields property of:
then put the following code into the OnCalculateField event:
ShowMessage(ARow.ByName('FORENAME').AsString+' '+ARow.ByName
then it (incorrectly) returns:
"Stuart Hunt "
in other words, in this event (and it seems only in this event) the
AsString method is padding the field out to its maximum width. I've
put together a very simple database and example application that
shows this that I can send if it would help.
Stuart Hunt