Casio ClassPad 300 Programming Manual page 123

Sdk programming guide
Hide thumbs Also See for ClassPad 300:
Table of Contents

Advertisement

The class only has two member functions, Read() and Write().
void
Read(CPReadFile &f);
void
Write(CPWriteFile &f);
Once you have created a CPMEMFileHeader, you simply call its Read() function if you
are reading in a file or its Write() function if you are writing out a file. For example,
here is the Read() function from AddressDocument.cpp:
// Application Type
const PEGCHAR* ADDRESSBOOK_MEMTYPE_HEADER = "AddressBook";
//Data Type
const PEGCHAR* ADDRESSBOOK_MEMTYPE_SAVED_STATE = "Data";
void AddressDocument::Read(CPReadFile &f)
{
if (f.FileExists())
{
//Create the file header with the application and data type
CPMEMFileHeader header(ADDRESSBOOK_MEMTYPE_HEADER,
// Read in the header (basically reads the header and
// moves the file pointer to the start of the contact data)
header.Read(f);
if(f.IsNotError())
{
}
}
}
As you can see it is simply a matter of creating a header and then reading it in before
reading in the contacts in the file. Writing a file is done very similarly – before writing
the contacts a header is written to the file:
void AddressDocument::Write(CPWriteFile &f)
{
// Create the header
CPMEMFileHeader header(ADDRESSBOOK_MEMTYPE_HEADER,
// Write the Header
header.Write(f);
if(f.IsNotError())
{
// Call the ContactArray's Write function
contacts.Write(f);
ADDRESSBOOK_MEMTYPE_SAVED_STATE);
// Call the ContactArray's Read Function
// (which in turn calls the Contact's Read Function)
contacts.Read(f);
ADDRESSBOOK_MEMTYPE_SAVED_STATE);
123

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents