Mach doch einfach keine direkten Variablen sondern Properties. Das Setzen der Property setzt ein "was Changed"-Flag auf True das du abfragen kannst.
Delphi-Quellcode:
program Project22;
{$APPTYPE CONSOLE}
{$R *.res}
uses System.SysUtils;
type
TMyRecord =
record
strict private var
FSomeName:
String;
FIsChanged: Boolean;
strict private
function GetSomeName():
String;
procedure SetSomeName(
const Value:
String);
public
function isChanged(): Boolean;
procedure resetChangedFlag();
property SomeName:
String read GetSomeName
write SetSomeName;
end;
{ TMyRecord }
function TMyRecord.GetSomeName():
String;
begin
Result := FSomeName;
end;
function TMyRecord.isChanged(): Boolean;
begin
Result := FIsChanged;
end;
procedure TMyRecord.resetChangedFlag();
begin
FIsChanged := False;
end;
procedure TMyRecord.SetSomeName(
const Value:
String);
begin
if Value.Equals(FSomeName)
then Exit;
FIsChanged := true;
FSomeName := Value;
end;
var
myRecord: TMyRecord;
begin
try
Write('
record is changed: '); WriteLn( myRecord.isChanged() );
myRecord.SomeName := '
Hallo Welt';
Write('
record is changed: '); WriteLn( myRecord.isChanged() );
myRecord.resetChangedFlag();
Write('
record is changed: '); WriteLn( myRecord.isChanged() );
except
on E:
Exception do
Writeln(E.ClassName, '
: ', E.
Message);
end;
readln;
end.