Writing To Mcs - Casio ClassPad 300 Programming Manual

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

Advertisement

If we look closely at the Contact class, we see it is just composed of CPStrings that hold
all the information for a contact. Therefore, the Contact class's Read() function will just
be each one of these CPStrings calling its Read() function:
// Reads a contact from a file.
// Each CPString just calls its read function
void Contact::Read(CPReadFile& f)
{
firstName.Read(f);
lastName.Read(f);
phone1.Read(f);
phone2.Read(f);
email.Read(f);
address.Read(f);
}
As you can see, the Read() functions that you create will usually just call that class's data
members' Read() functions.

Writing to MCS

To write to MCS, you must create an instance of the CPWriteMCSFile class. The
following constructors are available:
CPWriteMCSFile (UCHAR type)
CPWriteMCSFile (const char *name, const char *path=NULL, UCHAR type=0)
If you use the first constructor, you must set the name and path of the file before trying to
write.
When you create a MCSWriteFile you do not provide a file size in the constructor. Upon
creation no memory will be allocated and any write functions you call will not actually
write to memory. The write functions will, however, compute the size of the object
written. The function Realize() can then be used to allocate the memory for the file. A
second call to the write functions will then write the file to memory. This method allows
you to write a file without determining how much space the file will require in memory
prior to creation.
CPWriteMCSFile does not have any functions that write to memory. Like
CPReadMCSFile, it inherits a few write functions from its base class CPWriteFile:
int WriteBytes(void *buffer, int nBytes);
virtual void WriteByte(char c);
void WriteWord(WORD w);
void WriteInt(int ii);
void WriteDouble(OBCD xx);
Here is a simple example of creating a CPMCSWriteFile and writing an int:
CPWriteMCSFile f(FILE_NAME, FOLDER_NAME);
f.WriteInt(8);
120

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents