0
我想從一個函數返回多個數組。 我的代碼看起來是這樣的:返回多個數組穩定性
struct Document{
bytes32 _documentNumber;
bytes32 _documentStatus;
uint _documentScore;
}
mapping(bytes32=>Document) public mapDocuments; // Holds Docno as key
mapping(address=>bytes32[]) public mapUserDocNos; // Holds User address as key with valuehaving array of all document nos
mapping(bytes32=>DocumentDetails) public mapDocumentDetails; // Holds Docno as key
//,我在地圖中存儲數據是這樣的:
function addDocument(address _user, bytes32 _docNo,
bytes32 _documentStatus,uint _documentScore,
uint _createdDateStr) returns (bool status){
DocumentDebuggingLog(block.timestamp, "Step 1",_user);
Document memory document;
DocumentDebuggingLog(block.timestamp, "Step 2",_user);
document._customerAccountAddress= _user;
document._documentNumber= _docNo;
document._documentScore=_documentScore;
document._documentStatus=_documentStatus;
mapDocuments[_docNo]=document;
mapUserDocNos[_user].push(_docNo);
return true;
}
//試圖檢索:
function getDocumentListByUser(address _user) returns (bytes32[] _docNumber,
bytes32[] _docStatus,uint[] _docScore){
bytes32[] _documentNumber;
bytes32[] _documentStatus;
uint[] _documentScore;
DocumentDebuggingLog(block.timestamp, "step 1 in getDocumentListByUser",_user);
for(uint i=0;i<mapUserDocNos[_user].length;i++){
//bytes32 dockey= mapUserDocNos[_user][i];
//DocumentDebuggingLog(block.timestamp, dockey,_user);
_documentNumber.push(mapDocuments[mapUserDocNos[_user][i]]._documentNumber);
_documentStatus.push(mapDocuments[mapUserDocNos[_user][i]]._documentStatus);
_documentScore.push(mapDocuments[mapUserDocNos[_user][i]]._documentScore);
}
return (_documentNumber,_documentStatus,_documentScore);
}
但我不能從上面的函數獲取任何數據。我在做錯了什麼?有沒有其他的方法可以從一個函數返回多個數組?
感謝@Abhishek!它的工作。 – santosh