怎么写自定义函数返回BYTE类型的数组,求教!
自己胡乱写的不对:
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);
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;