怎么写自定义函数返回BYTE类型的数组,求教!
自己胡乱写的不对:
- Delphi(Pascal) code
function Read(DiZhi:Integer;Wei:Integer):Byte;var MyV:array[0..5] of Byte;begin MyV[0]:= byte($68); MyV[1]:= byte($1B); MyV[2]:= byte($1B); MyV[3]:= byte($68); MyV[4]:= byte($+DiZhi); MyV[5]:= byte($+Wei);
怎么把MYV的BYTE类型数组里的数据全部返回出来,也就是说我执行函数Read(0,3)
那么返回的Read是也是BYTE型的byte($68)+byte($1B)+byte($1B)+byte($68)+byte($0)+byte($3);
请教怎么样的函数应该怎么写啊?
[解决办法]
将数组定义为类,返回类
google “delphi 返回数组”
[解决办法]
- Delphi(Pascal) code
type TArr= Array of Byte;function Read(DiZhi:Integer;Wei:Integer):TArr;var MyV:TArr;begin Setlength(MyV,6); MyV[0]:= $68;{本来就Byte类型,不用强制转换} MyV[1]:= $1B; MyV[2]:= $1B; MyV[3]:= $68; MyV[4]:= $+DiZhi; MyV[5]:= $+Wei; Result:=MyV ;end;调用var MyV:TArr;begin MyV:=Read(0,3); ...end;