Subject Re: [IBO] Syntax
Author TeamIBO
> I use something like:
> var
> fldno_FirstField : integer;
> fldno_SecondField : integer;

> Then just before the looping i do:

> fldno_FieldField := SomeTable.FieldByName('FirstField').FieldNo;

> and then do the loop:
> ...
> n := SomeTable.Fields[fldno_FieldField].AsInteger;
> ...

I prefer direct field references...

var
FirstField, SecondField: TIB_Column;
...
FirstField := SomeTable.FieldByName( 'FirstField' );
...
whatever := FirstField.AsInteger;


You even save a couple of clock cycles because their is no need for
the array offset resolution :-)

The downside being that the references are only valid for the current
prepared phase. If something happens that causes the query to be
reprepared then the references will be invalid. So either keep such
references inside the one function or maintain the references in the
PreparedChanged event handler.


--
Geoff Worboys - TeamIBO
Telesis Computing