Subject Re: [IBO] Still having problems with OnCalculateField
Author Stuart Hunt
--- In IBObjects@yahoogroups.com, 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:

FORENAME="Stuart"
SURNAME="Hunt"

then have a TIB_Query that returns both these fields - i.e.
select FORENAME, SURNAME from STAFF

if you do:
ShowMessage(IB_Query.FieldByName
('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
width.
If, however, you add a calculated field to the
TIB_Query.CalculatedFields property of:
FULLNAME=CHAR (46)
then put the following code into the OnCalculateField event:
ShowMessage(ARow.ByName('FORENAME').AsString+' '+ARow.ByName
('SURNAME').AsString);
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.
thanks,
Stuart Hunt