Subject Re: [IBO] Still having problems with OnCalculateField
Author Stuart Hunt
--- In, Helen Borrie <helebor@t...> wrote:
> At 04:08 PM 14/01/2004 +0000, you wrote:
> >Hi,
> >further to the posting I made earlier, i'm still having problems
> >OnCalculateField events padding string fields in IB Objects 4.3Aa.
> >complete system is:
> >Delphi 4 update pack 2(I know this is very old - I'm about to
> >it but decided to do the upgrade a bit at a time)
> >InterBase 7.1
> >IB Objects 4.3Aa
> >Windows XP Service Pack 1
> >
> >The problem is still that when I use ARow.ByName('XXX').AsString in
> >the OnCalculatedField method to get a field value it is padding out
> >string fields where it didn't used to. For example, code to return
> >someones name:
> >
> >procedure TfrmDocSel.qryDocumentCalculateField(Sender:
> >ARow: TIB_Row; AField: TIB_Column);
> >begin
> >AField.AsString:=ARow.ByName('FORENAME').AsString+' '+
> >ARow.ByName('SURNAME').AsString;
> >end;
> >
> >Now returns "Stuart Hunt " instead of "Stuart
> >Hunt". I use calculated fields a lot and therefore don't want to
> >to manually trim the fields for all these cases.
> Are you sure these columns are varchar and not char? If you are
using IB
> 7.1, there is nothing to trim on varchars, so I'm suspicious. :-)
> If this *is* the problem, then use the FieldsTrimming attribute to
> eliminate padding in whatever way you desire. This applies
trimming at the
> field level, either in the dataset, or globally if you want, in the
> connection component.
> >I have also ensured that the connection's DefaultNoTrimming
> >is FALSE.
> This doesn't trim char types, afaik.
> Helen

thanks for this. The fields ARE Char fields - a CHAR (15) and a CHAR
(30). I assume that what you're saying therefore is that IB Objects
now returns Char fields untrimmed? The thing that confuses me about
this is that if you use AsString anywhere outside of the
OnCalculateField event it trims the field fine. If we do have to use
FieldsTrimming I assume we simply use:
to right trim?
Stuart Hunt