In the following Delphi code snippet, how to correctly inter-link TFieldChangeEvent…
- User
In the following Delphi code snippet, how to correctly inter-link TFieldChangeEvent without compiler error?
type TFieldChangeEvent = procedure(Sender: TQryRecInfo; const FieldName: string) of object;
/// /// Base class for query record information /// Use descendants of this class to represent specific database records. /// TQryRecInfo = class private FDirtyFields: TDictionary<string, Boolean>; FPreviousValues: TDictionary<string, TValue>; procedure SetInfo(Index: Integer; const Value: TValue); public constructor Create; destructor Destroy; override;
code// Methods to set nullable fields procedure SetInfoNullableString(Index: Integer; const Value: TNullable<string>); procedure SetInfoNullableInteger(Index: Integer; const Value: TNullable<Integer>); procedure SetInfoNullableInt64(Index: Integer; const Value: TNullable<Int64>); procedure SetInfoNullableExtended(Index: Integer; const Value: TNullable<Extended>); procedure SetInfoNullableCurrency(Index: Integer; const Value: TNullable<Currency>); procedure SetInfoNullableDateTime(Index: Integer; const Value: TNullable<TDateTime>); procedure SetInfoNullableBoolean(Index: Integer; const Value: TNullable<Boolean>); procedure SetInfoNullableVariant(Index: Integer; const Value: TNullable<Variant>); // Methods to set non-nullable simple types procedure SetInfoCurrency(Index: Integer; const Value: Currency); procedure SetInfoString(Index: Integer; const Value: string); procedure SetInfoInteger(Index: Integer; const Value: Integer); procedure SetInfoInt64(Index: Integer; const Value: Int64); procedure SetInfoExtended(Index: Integer; const Value: Extended); procedure SetInfoDateTime(Index: Integer; const Value: TDateTime); procedure SetInfoBoolean(Index: Integer; const Value: Boolean); procedure SetInfoVariant(Index: Integer; const Value: Variant); // Methods to handle dirty fields function IsFieldDirty(const FieldName: string): Boolean; procedure ClearDirtyFlags; property DirtyFields: TDictionary<string, Boolean> read FDirtyFields; // Methods to handle previous values function GetPreviousValue(const FieldName: string): TValue; procedure ClearPreviousValues; property PreviousValues: TDictionary<string, TValue> read FPreviousValues; /// <summary> /// Retrieves the formatted text for a given field based on the FmtProp attribute. /// </summary> function GetFormattedText(const FieldName: string): string; /// <summary> /// Fetches data for this record from the database based on the provided SQL. /// </summary> procedure Fetch(DBConn: TUniConnection; const QryTxt: string); - Assistant
To inter-link and correctly use the
TFieldChangeEventin the provided Delphi code without a compiler error, you need to ensure that the event declaration is correctly attached to events in theTQryRecInfoclass. The process typically involves: - User
The problem that I want to address is that TFieldChangeEvent is defined before TQryRecInfo , and the compiler gives an error: [dcc32 Error] orm_utils.pas(20): E2003 Undeclared identifier: 'TQryRecInfo'
- Assistant