Die Antwort vom Schönen Günter ist wohl das Besste für mich.
Ich denke, so werde ich es verwenden.
Delphi-Quellcode:
program DataRecord;
{$APPTYPE CONSOLE}
uses
SysUtils;
type
TDataItemString = record
private
fValue: string;
fChanged: boolean;
fIsNull: Boolean;
procedure SetValue(const Value: string);
procedure SetIsNull(const Value: Boolean);
public
property Value: string read FValue write SetValue;
property IsNull: Boolean read FIsNull write SetIsNull;
function Changed: Boolean;
procedure ResetChanged;
end;
TDataAdresse = record
nachname: TDataItemString;
Vorname: TDataItemString;
Strasse: TDataItemString;
procedure ResetChanged;
function RecordChanged: boolean;
end;
{ TDataItemString }
function TDataItemString.Changed: Boolean;
begin
Result := fChanged;
end;
procedure TDataItemString.ResetChanged;
begin
fChanged := False;
end;
procedure TDataItemString.SetIsNull(const Value: Boolean);
begin
FIsNull := Value;
end;
procedure TDataItemString.SetValue(const Value: string);
begin
if fIsNull or (not SameStr(Value,fValue)) then
begin
FValue := Value;
fChanged := True;
fIsNull := False;
end;
end;
{ TDataAdresse }
function TDataAdresse.RecordChanged: boolean;
begin
Result :=
nachname.Changed or
Vorname.Changed or
Strasse.Changed;
end;
procedure TDataAdresse.ResetChanged;
begin
nachname.ResetChanged;
Vorname.ResetChanged;
Strasse.ResetChanged;
end;
var
lataAdresse: TDataAdresse;
begin
lataAdresse.nachname.Value := 'Meier';
lataAdresse.Vorname.Value := 'Hans';
lataAdresse.Strasse.Value := 'Hauptstr';
lataAdresse.ResetChanged;
lataAdresse.Vorname.Value := 'Peter';
end.