type
TProcArray=array of byte;var byteList:TProcArray;通过SetLength(byteList,cmdList.Count)来改变大小现想求得byteList数组元素的个数,怎么求得?
用了SizeOf返回4,varArrayOf提示Incompatible type:'Array' and 'TProcArray',用High提示Incompatible type
TProcArray=array of byte;var byteList:TProcArray;通过SetLength(byteList,cmdList.Count)来改变大小现想求得byteList数组元素的个数,怎么求得?
用了SizeOf返回4,varArrayOf提示Incompatible type:'Array' and 'TProcArray',用High提示Incompatible type
type
TProcArray=array of byte;
var
byteList:TProcArray;
begin
SetLength(bytelist, 10);
ShowMessage(IntToStr(Length(bytelist)));
end;
begin
cmdList:=TStringList.Create;
for i:=0 to cmdList.Count-1 do
byteList[i]:=StrToInt(cmdList[i]);
cmdList.Free;
Result:=byteList;
end;
2、cmdList的内容没有赋值,也就是长度为0
3、buteList没有用SetLength设置长度。楼主可以先测试一下我写的那个程序。应该找一下其他的原因了。
另外,你那段代码我试了,确实可以,我也讷闷为什么我这个不可以,难道是传回来以后结构变了?function StringToByte(str:string):TProcArray;
var
cmdList:TStringList;
i:Integer;
byteList:TProcArray;
stringsList:TStringList;
begin
cmdList:=TStringList.Create;
ExtractStrings([','], [], PChar(str), cmdList);
SetLength(byteList,cmdList.Count);
for i:=0 to cmdList.Count-1 do
byteList[i]:=StrToInt(cmdList[i]);
cmdList.Free;
Result:=byteList;
end;
后来我直接用showmessage(IntToStr(Length(byteList)))显示,确实是可以显示其大小,但就是不明白Delphi自带的监视器为什么监视不到值?在这里非常感谢Dlwxn(Dlwxn) 耐心的回答!!