CStdioFile fp;
CString strFileName,cmdRecord;
byte cmd,addr,data0,data1,data2,data3;
CFileDialog MyDialog(true,"","",OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, "Text Files (*.txt)|*.txt|"); // open file menu (construct CFileDialog object)
if (MyDialog.DoModal()==IDOK)
{
strFileName = MyDialog.GetPathName();
if(!fp.Open(strFileName,CFile::modeRead |CFile::typeText))
{
MessageBox("Cannot open command file","Multi-Ucodes",MB_ICONERROR|MB_OK); // file cannot be opened (not existing)
return;
}
else
{
USHORT numRecord="0";
while(fp.ReadString(cmdRecord))
{
if (cmdRecord.Left(1) != '#')
{
sscanf(cmdRecord,"%x%x%x%x%x",&addr,&cmd,&data1,&data2,&data3);
numRecord++;
if (numRecord >= 100)
{
MessageBox("Warning: command list is too large,only 100 cmd can be executed!", "Multi-Ucode", MB_ICONWARNING|MB_OK);
break;
}
}
}
fp.Close();
}
}
文章评论(0条评论)
登录后参与讨论