FieldGet() Bug in CalcFields.
Posted by Teo Fonrouge on 2002-04-08 15:30:00
I have found a strange behavior using the function FieldGet('fieldname') in a calculated field. Seems that the FieldGet() function moves the record pointer when it retrieves the field value.
status: CLOSED Urgency: MEDIUM As Of: 2002-04-08 15:30:00
Comment:
The problem with FieldGet(), StringGet(), etc. is that they are low-level calls that use the current active buffer to retrieve the data. This works except in a refresh in a grid where the TDataSet has cached several records. FieldGet always uses the same buffer because it operates at a level below where TDataset is switching buffer pointers.
While the FieldGet works in normal circumstances by grabbing the ActiveBuffer pointer contained in TDataset, in the refreshing of the grid, this is not the correct buffer to get.
You can replace the code in gs6_HalcnDB.pas to fix this. Just replace the CheckActiveSet method with the code below:
procedure THalcyonDataSet.CheckActiveSet;
var
Buf: PChar;
begin
CheckActive;
if not FUpdatingIndexDesc then
begin
GetActiveRecBuf(Buf);
if Buf = nil then Buf := ActiveBuffer;
SetCurRecord(Buf);
end;
end;

