CIP3 file read process
OK, here is my latest attempt to clean it up.
With the Unicode switch ON, it compiles with No errors and does work.
As you see errors in my code (Joe) please explain how to fix?
void CCIPreadTop::CIPFileRead(CString CipName)
{
int a;
CString stmp;
CFile f;
CFileException ex;
if(!f.Open(CipName, CFile::modeRead, &ex))
{ //open failed
TCHAR szError[1024];
ex.GetErrorMessage(szError, 1024);
CString erstr;
erstr.Format(_T("%s"), szError);
MessageBox(erstr, _T("Adelphi"));
return;
}
ULONGLONG len = f.GetLength();
CByteArray buffer;
buffer.SetSize(len + 1);
if(!f.Read(buffer.GetData(), len))
{ //read failed
f.Close();
MessageBox(_T("Unable to Read File"), _T("Adelphi"));
return;
}
buffer[len] = 0;
f.Close();
for(ULONGLONG i=0; i<buffer.GetSize(); i++){
if (buffer[i] == 0x00)
buffer[i] = 0x01;
}
CipStr = (LPCSTR)buffer.GetData();
a = CipStr.Find("CIP3PreviewImageWidth");
if (a == -1){
AfxMessageBox(_T("CIP3PreviewImageWidth Keyword Not Found"));
return;
}
a += 22;
stmp.Empty();
while (CipStr[a] != 0x20){ //build the width number
stmp += CipStr[a];
a++;
}
PreviewWidth = _ttoi(stmp);
a = CipStr.Find("CIP3PreviewImageHeight");
if (a == -1){
AfxMessageBox(_T("CIP3PreviewImageHeight Keyword Not Found"));
return;
}
a += 23;
stmp.Empty();
while (CipStr[a] != 0x20){ //build the height number
stmp += CipStr[a];
a++;
}
PreviewHeight = _ttoi(stmp);
}