The right frame displays
pseudo-code for reading a JellyFish position file,
"position.pos".
The writing routine will be the opposite.
For example, to read the level, the example shows:
ar >>
w; level = (int) w;
To write to file, use:
ar << (WORD)
level;
and so on.
JellyFish is written in C++ using Microsoft Foundation
Classes (MFC). The classes CFile and CArchive are MFC
classes, WORD is a Windows SDK data type.
What you'll have to do to be able to read from or write
to a file, is first to create and open a CFile object.
The Open command needs to parameters: The file name and a
flag specifying whether to read or to write.
After that, you also create and open a CArchive object.
Now you need four parameters for the Open command: A
pointer to the CFile object, a flag specifying whether to
read (load) or to write (store), an integer specifying
the size of the internal file buffer, and a pointer to
the same buffer.
In the end, after reading all data, the CFile and the
CArchive objects must be closed.
|