Delphi 10.2: 我有一个变量记录定义:
type
TIPMCCmdPacket = packed record
TransactionID: Word;
FuncCode: Word;
DataLen: Word;
case byte of
//raw data buffer
0: (RawBuf: Array[0..16383] of Byte);
//error response
1: (ErrCode: Word; //error type code
ErrLen: Word; //length of error msg/data
ErrBuf: Array[0..16379] of AnsiChar); //err msg buffer
//normal response, usually an ansistring
2: (BufCnt: Word; //byte count
Buffer: Array[0..16381] of Byte); //response data
//structured-data response
3: (RecType: Word; //type code of record
RecCnt: Word; //# of records
RecSize: Word; //size of each record
RecBuf: Array[0..16377] of Byte); //data block
end;
我想为这个记录添加一些辅助函数,但是普通记录辅助函数的语法在变体记录中使用会引发语法错误,并且该语言参考文献中没有提及如何在变体记录中使用辅助函数的情况。我是否有所遗漏,有没有其他方法可以做到这一点?
TIntegerHelper
和TStringHelper
。(我在我的 A 中使用TIntegerHelper
!) - Andreas Rejbrand