|
-
March 30th, 1999, 01:45 PM
#1
urgent !! serialization-problems by loadind array
Hi
I am trying to load from a file, but do not know when it is the EOF.
Therefore I use a while in my serialization to do the serialization until it is the end of the file. But with my code
the while is done only once.
Hopefully you can help me.
void Telefon::load()
{
CFile Telefonbuch;
if(!Telefonbuch.Open("C:\\tel\\tel.sv", CFile::modeCreate |
CFile::modeNoTruncate |
CFile::modeReadWrite))
{
}
CArchive ar(&Telefonbuch, CArchive::load);
Serialize(ar);
ar.Close();
Telefonbuch.Close();
}
void Telefon::Serialize(CArchive &ar)
{
int i = 0;
CObject::Serialize(ar);
if(ar.IsStoring())
{
while(i < iterator_)
{
ar << tbuch[i].name_ ;
ar << tbuch[i].vorname_;
ar << tbuch[i].str_;
ar << tbuch[i].plz_;
ar << tbuch[i].nummer_;
ar << tbuch[i].fax_;
ar << tbuch[i].email_;
ar << tbuch[i].firma_;
ar << tbuch[i].handy_;
ar << tbuch[i].home_;
i++;
}
}
else
{
CString name, vorname, str, plz, nummer, fax, email,
firma,handy, home;
CFile *pFile = ar.GetFile();
//LONG lOff = 0;
//DWORD endpos = pFile->Seek(0L, CFile::end);
pFile->SeekToBegin();
//DWORD pos = pFile->GetPosition();//Seek(0L,
//pFile- >begin);
while(!pFile->GetPosition())
{
ar >> name;
ar >> vorname;
ar >> str;
ar >> plz;
ar >> nummer;
ar >> fax;
ar >> email;
ar >> firma;
ar >> handy;
ar >> home;
enter(name, vorname, str, plz, nummer, fax, email,
firma,handy, home);
// pos = pFile->GetPosition();
}
}
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|