I have this class defined
TParamType = (ptDriverID, ptServer, ptHost, ptUser, ptPassword, ptPort, ptDatabase, ptOSAuth, ptPooled, ptUnicode);
TDataType = (dtInteger, dtString, dtBoolean, dtYesNo, dtPassword);
TParam = record
Index: Byte;
Typ: TParamType;
RegKeyName: String;
ConnName: String;
DataType: TDataType;
Caption: String;
Value: String;
Text: String;
Default: String;
Basic: Boolean;
Enabled: Boolean;
Mandatory: Boolean;
end;
TParams = class(TObject)
private
FParam: array of TParam;
function GetParam(Index:Byte): TParam;
procedure SetParam(Index:Byte;Value:String;Text:String);
public
constructor Create;
destructor Destroy;
property Param[Index: Byte]: TParam read GetParam write SetParam;
procedure Enable(ServerType:TServerType);
end;
I get this error: 'E2008 Incompatible types' to the code line
property Param[Index: Byte]: TParam read GetParam write SetParam;
Any idea why I get this error for this property?
property Param
is a TParam
. Therefore, SetParam
needs to receive the Index
into the array and a TParam
to put there. Your setter instead provides the index and two strings, neither of which are a TParam
.
The proper setter would be
procedure SetParam(Index: Byte; const Value: TParam);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.