EasyManuals Logo
Home>Casio>Calculator>ClassPad 300

Casio ClassPad 300 Programming Guide

Casio ClassPad 300
125 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #122 background imageLoading...
Page #122 background image
for(int i=0; i<GetSize();i++)
{
Contact *s = (Contact*)GetAt(i);
s->Write(f);
}
}
All that happens here is that we write out the total number of contacts that will be stored
as an integer, then call each contact’s Write() function to write the contact. Here is the
code for the Contact Class’s Write() function:
// Writes a contact to a file. Since a contact is just a bunch of
// CPStrings, every CPString just writes itself.
void Contact::Write(CPWriteFile& f)
{
firstName.Write(f);
lastName.Write(f);
phone1.Write(f);
phone2.Write(f);
email.Write(f);
address.Write(f);
}
Any class that you create that you wish to save to MCS should also have its own Write()
function.
CPFile Headers
We mentioned earlier that all CPFiles of type IMU_MCS_TypeMem should have a file
header. This header identifies what application uses the file and what type of data is
contained in the file. So far we haven’t dealt with headers when either reading or writing
in the AddressBook example. This is because we haven’t yet discussed where the
ContactArray class’s Write or Read methods are called.
Generally, the ClassPad uses a document/view approach to display data on the screen. A
document class handles reading/writing the data, and manages the data while the
application is running. A view, on the other hand, manages how this data is displayed.
In the AddressBook example you will notice that there is an AddressDocument class that
is derived from CPDocument. This is the AddressBook’s document class. It contains the
array of contacts and the Read() and Write() methods to save the array.
It is these Read() and Write() methods that call the ContactArray object’s Read() and
Write() functions and handles the creation of the file header.
To create a file header, we use the CPMEMFileHeader class. The constructor simply
takes in a PEGCHAR* of your application’s name and the name of the data. You can
optionally supply it with a major and minor version number:
CPMEMFileHeader (const PEGCHAR *AppName, const PEGCHAR *DataName,
PEGCHAR MajorVersion=1, PEGCHAR MinorVersion=0);
122

Table of Contents

Other manuals for Casio ClassPad 300

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Casio ClassPad 300 and is the answer not in the manual?

Casio ClassPad 300 Specifications

General IconGeneral
BrandCasio
ModelClassPad 300
CategoryCalculator
LanguageEnglish

Related product manuals