I am using RAD XE7. In my Delphi application I want to set default values for fields of Records.
I tried following code, but it does not compile, I know it is wrong. I there any another way?
TDtcData = record
TableFormat : TExtTableFormat = fmNoExtendedData;
DTC : integer = 0;
Description : string = 'Dummy';
Status : TDtcStatus;
OccurenceCnt : integer =20;
FirstDTCSnapShot: integer;
LastDTCSnapShot: integer;
end;
If you want to define a partially initialized record, just declare a constant record, but omit those parameters not needing default values:
Type
TDtcData = record
TableFormat : TExtTableFormat;
DTC : integer;
Description : string;
Status : TDtcStatus;
OccurenceCnt : integer;
FirstDTCSnapShot: integer;
LastDTCSnapShot: integer;
end;
Const
cDefaultDtcData : TDtcData =
(TableFormat : fmNoExtendedData;
DTC : 0;
Description : 'Dummy';
OccurenceCnt : 20);
var
someDtcData : TDtcData;
begin
...
someDtcData := cDefaultDtcData;
...
end;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With