void __fastcall TForm_PRCVersion::GetPosRecord(int nIndex) //nIndex:记录序号
{
int nRecvCount = 10; //每次最大取10条
m_pDllCall->nInfoReturn = nFail;
m_pDllCall->lpSetWaitTime(m_pDllCall->m_pDevice, 2000); //取收费记录------------------------
int nTryTimes = 5;
do
{
m_pDllCall->m_pActReturn = m_pDllCall->lpStartICDMCmd(m_pDllCall->m_pDevice, m_pDllCall->nTagAdr,
cmd_GetPosRecord, &nRecvCount, sizeof(int));//取n条记录
if(m_pDllCall->m_pActReturn != NULL)
{
m_pDllCall->nInfoReturn = m_pDllCall->lpGetCmdResult(m_pDllCall->m_pActReturn);
if(m_pDllCall->nInfoReturn == nRecvSuccess)
{
int nLength = m_pDllCall->lpGetSizeOfData(m_pDllCall->m_pActReturn);
int nCount = nLength/sizeof(PosRecordStruct);
Label_RecvCount->Caption = IntToStr(nCount + StrToInt(Label_RecvCount->Caption));//显示记录条数
PosRecordStruct *pRecordBuffer = new PosRecordStruct[nCount];
PosRecordStruct *pBuffer = pRecordBuffer;
PosRecordStruct stuPosRec;
m_pDllCall->lpGetData(m_pDllCall->m_pActReturn, pRecordBuffer, nLength);
for(int iLoop = 0; iLoop < nCount; iLoop ++) //nCount次循环,每次写一条
{
stuPosRec = *(pBuffer ++);
/*int nOK =*/ m_pDllCall->WritePOSFile(nIndex, stuPosRec);//写文本文件
nIndex ++;
}
delete []pRecordBuffer;
}
}
m_pDllCall->lpEndICDMCmd(m_pDllCall->m_pActReturn);
//返回结果-------------------------------------------------------------
if(m_pDllCall->nInfoReturn == nRecvSuccess)
{
m_pDllCall->m_pActReturn = m_pDllCall->lpStartICDMCmd(m_pDllCall->m_pDevice, m_pDllCall->nTagAdr,
cmd_DelRecord, NULL, 0); //删除记录
m_pDllCall->lpEndICDMCmd(m_pDllCall->m_pActReturn);
}
if(m_pDllCall->nInfoReturn == nRecvSuccess) //成功取信息
nTryTimes = 5;
else if(m_pDllCall->nInfoReturn == nRecvEmpty) //记录取完
nTryTimes = 0;
else
nTryTimes--;
Label_ShowRlt->Caption = m_pDllCall->ShowMessage(m_pDllCall->nInfoReturn, nPRCChinese);//显示命令结果
} while(nTryTimes != 0);
}
{
int nRecvCount = 10; //每次最大取10条
m_pDllCall->nInfoReturn = nFail;
m_pDllCall->lpSetWaitTime(m_pDllCall->m_pDevice, 2000); //取收费记录------------------------
int nTryTimes = 5;
do
{
m_pDllCall->m_pActReturn = m_pDllCall->lpStartICDMCmd(m_pDllCall->m_pDevice, m_pDllCall->nTagAdr,
cmd_GetPosRecord, &nRecvCount, sizeof(int));//取n条记录
if(m_pDllCall->m_pActReturn != NULL)
{
m_pDllCall->nInfoReturn = m_pDllCall->lpGetCmdResult(m_pDllCall->m_pActReturn);
if(m_pDllCall->nInfoReturn == nRecvSuccess)
{
int nLength = m_pDllCall->lpGetSizeOfData(m_pDllCall->m_pActReturn);
int nCount = nLength/sizeof(PosRecordStruct);
Label_RecvCount->Caption = IntToStr(nCount + StrToInt(Label_RecvCount->Caption));//显示记录条数
PosRecordStruct *pRecordBuffer = new PosRecordStruct[nCount];
PosRecordStruct *pBuffer = pRecordBuffer;
PosRecordStruct stuPosRec;
m_pDllCall->lpGetData(m_pDllCall->m_pActReturn, pRecordBuffer, nLength);
for(int iLoop = 0; iLoop < nCount; iLoop ++) //nCount次循环,每次写一条
{
stuPosRec = *(pBuffer ++);
/*int nOK =*/ m_pDllCall->WritePOSFile(nIndex, stuPosRec);//写文本文件
nIndex ++;
}
delete []pRecordBuffer;
}
}
m_pDllCall->lpEndICDMCmd(m_pDllCall->m_pActReturn);
//返回结果-------------------------------------------------------------
if(m_pDllCall->nInfoReturn == nRecvSuccess)
{
m_pDllCall->m_pActReturn = m_pDllCall->lpStartICDMCmd(m_pDllCall->m_pDevice, m_pDllCall->nTagAdr,
cmd_DelRecord, NULL, 0); //删除记录
m_pDllCall->lpEndICDMCmd(m_pDllCall->m_pActReturn);
}
if(m_pDllCall->nInfoReturn == nRecvSuccess) //成功取信息
nTryTimes = 5;
else if(m_pDllCall->nInfoReturn == nRecvEmpty) //记录取完
nTryTimes = 0;
else
nTryTimes--;
Label_ShowRlt->Caption = m_pDllCall->ShowMessage(m_pDllCall->nInfoReturn, nPRCChinese);//显示命令结果
} while(nTryTimes != 0);
}
xx: integer;
yy: integer;
zz :integer;
end;
PosRecordStruct *pRecordBuffer = new PosRecordStruct[nCount];
[align=left]PosRecordStruct *pBuffer = pRecordBuffer;
PosRecordStruct stuPosRec;
m_pDllCall->lpGetData(m_pDllCall->m_pActReturn, pRecordBuffer, nLength);
for(int iLoop = 0; iLoop < nCount; iLoop ++) //nCount次循环,每次写一条
{
stuPosRec = *(pBuffer ++);
/*int nOK =*/ m_pDllCall->WritePOSFile(nIndex, stuPosRec);//写文本文件
nIndex ++;
} [/align]
主要是这段,读出来的数组第一个是正确的,后面的都错了,可能是数组中含有'\n'如何将这个去掉
如果是这样的话好像第二个就可以stuPosRec.xx=stupos.zz shr 8
procedure TForm_PRCVersion.GetPosRecord(var nIndex : integer) ;
var
nRecvCount : integer ;
nTryTimes : integer ;
nLength : integer ;
nCount : integer ;
pRecordBuffer:PosRecordStruct^ ;
pBuffer : PosRecordStruct^ ;
stuPosRec :PosRecordStruct ;
iLoop : integer ;
begin
nRecvCount := 10; //每次最大取10条
m_pDllCall.nInfoReturn := nFail;
m_pDllCall.lpSetWaitTime(m_pDllCall.m_pDevice, 2000); //取收费记录------------------------
nTryTimes := 5;
do
begin
m_pDllCall.m_pActReturn := m_pDllCall.lpStartICDMCmd(m_pDllCall.m_pDevice, m_pDllCall.nTagAdr,
cmd_GetPosRecord, @nRecvCount, sizeof(integer));//取n条记录
if(m_pDllCall.m_pActReturn <>nil )
begin
m_pDllCall.nInfoReturn := m_pDllCall.lpGetCmdResult(m_pDllCall.m_pActReturn);
if(m_pDllCall.nInfoReturn = nRecvSuccess) then
begin
nLength := m_pDllCall.lpGetSizeOfData(m_pDllCall.m_pActReturn);
nCount := nLength div sizeof(PosRecordStruct);
Label_RecvCount.Caption := IntToStr(nCount + StrToInt(Label_RecvCount.Caption));//显示记录条数
pRecordBuffer := new PosRecordStruct[nCount];
pBuffer := pRecordBuffer;
m_pDllCall.lpGetData(m_pDllCall.m_pActReturn, pRecordBuffer, nLength);
for (iLoop := 0 to nCount-1 ) do //nCount次循环,每次写一条
begin
stuPosRec := stuPosRec*(pBuffer ++);
/*int nOK =*/ m_pDllCall->WritePOSFile(nIndex, stuPosRec);//写文本文件
/*int nOK :=*/ m_pDllCall.WritePOSFile(nIndex, stuPosRec);//写文本文件
nIndex := nIndex +1 ;
end ;
dispose(pRecordBuffer);
end ;
end ;
m_pDllCall.lpEndICDMCmd(m_pDllCall.m_pActReturn);
//返回结果-------------------------------------------------------------
if(m_pDllCall.nInfoReturn = nRecvSuccess) then
begin
m_pDllCall.m_pActReturn := m_pDllCall.lpStartICDMCmd(m_pDllCall.m_pDevice, m_pDllCall.nTagAdr,
cmd_DelRecord, NULL, 0); //删除记录
m_pDllCall.lpEndICDMCmd(m_pDllCall.m_pActReturn);
end ;
if(m_pDllCall.nInfoReturn = nRecvSuccess) then //成功取信息
nTryTimes := 5
else if(m_pDllCall.nInfoReturn = nRecvEmpty) then //记录取完
nTryTimes := 0
else
nTryTimes := nTryTimes -1 ;
Label_ShowRlt.Caption := m_pDllCall.ShowMessage(m_pDllCall.nInfoReturn, nPRCChinese);//显示命令结果
end ;
while(nTryTimes <> 0);
end ;好多我都不知道什么类型的,乱搞上去啦,希望对你有点用啦