[fpc-devel] Recent changes to TField.SetData
Luiz Americo Pereira Camara
luizmed at oi.com.br
Wed Apr 6 03:52:39 CEST 2011
On 5/4/2011 04:38, michael.vancanneyt at wisa.be wrote:
>
>
> On Tue, 5 Apr 2011, LacaK wrote:
>
>>
>>>
>>>
>>> --or--
>>> introduce any new method (ValidateFieldData ? ;-))) and let tdatsset
>>> descendants use it:
>>> {$IFDEF FPC}
>>> ValidateFieldData(Field: TField; Buffer: Pointer);
>>> {$ENDIF}
>>>
>>> --or--
>>> some smarter solution ?
>>>
>> The whole code, which is repeated (and can be put in one place) is:
>>
>> if not (State in [dsEdit, dsInsert, dsFilter, dsCalcFields]) then
>> begin
>> DatabaseErrorFmt(SNotEditing,[Name],self);
>> exit;
>> end;
>> if (Field.FieldNo>0) and not (State in [dsSetKey, dsFilter]) then
>> begin
>> if ReadOnly then DatabaseErrorFmt(SReadOnlyField,
>> [Field.DisplayName], Self);
>> Field.Validate(Buffer);
>> end;
>
> You are right in your dislike.
>
> I will create a 'BeforeSetFieldData' in TDataset and put the code in
> there,
I still think that is overkill: adding a method to replace just two
lines of code.
Anyway, if you decide this way, consider another name. Sometimes is to
be called in the "middle" of SetFieldData
> and the same for 'AfterSetFieldData' with the OnChange code.
>
This one is a bit more odd since currently only bufdataset will use it
(or do you plan to replace the existing code in descendants?)
Luiz
More information about the fpc-devel
mailing list