}
}
Notice that these Read and Write methods take a CPReadFile f and CPWriteFile f as a
parameter. The methods that call these functions in AddressWindow.cpp are responsible
for actually creating this file:
void AddressWindow::Save()
{
CPWriteMCSFile f(FILE_NAME, FOLDER,IMU_MCS_TypeMem);
m_doc->Write(f);
f.Realize();
m_doc->Write(f);
}
//////////////////////////////////////////////////////////////////
void AddressWindow::Open()
{
CPReadMCSFile f(FILE_NAME, FOLDER,IMU_MCS_TypeMem);
m_doc->Read(f);
}
It is in this Save() function that the document’s Write() is called twice. The first time is
to allocate the memory needed for the file, and the second time is to actually write the file.
To summarize the following must be done on a read:
1) Create a CPReadMCSFile of type IMU_MCS_TypeMem
2) Create the appropriate header
3) Read in the header
4) Read in the data in the file
And you must follow these steps on a write:
1) Create a CPWriteMCSFile of type IMU_MCS_TypeMem
2) Create the appropriate header
3) Write the header
4) Write the data for the file
5) Call Realize();
6) Write the header
7) Write the data for the file
For more information about these classes, please refer to the ClassPad 300 SDK
Reference Guide or to the AddressBook example add-in.
124