> WriteDBProc (void *dataP, UInt32 *sizeP, void *userDataP)
> {
> StrCat (dataR,dataP);
> }
The data passed to the your callback function isn't strings, hence the sizeP
parameter. If you want to put the data into your dataR array, you'll need to
keep track of where you are with another variable. Something like this:
#define maxDatabaseSize 1024 // we can only handle databases up to this
size
Char Buffer[maxDatabaseSize];
UInt32 BytesWritten;
static Err WriteDBProc(void *dataP, UInt32 *sizeP, void *userDataP)
{
if (BytesWritten + *sizeP > maxDatabaseSize)
return exgMemError;
MemMove(&Buffer[BytesWritten], dataP, *sizeP);
BytesWritten += *sizeP;
return errNone;
}
...
Err err;
BytesWritten = 0;
err = ExgDBWrite(&WriteDBProc, NULL, "Address", NULL /*dbID*/, 0
/*cardNo*/);
if (err)
{
if (err == exgMemError)
...handle error somehow...
else
...handle error somehow...
}
Note that there are two or three databases for the Address application:
type creator name purpose
---- ------- --------- ------------
appl addr Address The application. Contains code and some/all
resources.
ovly addr Address_enUS The overlay. Contains localized resources.
(Palm OS >= 3.5)
DATA addr AddressDB The data. Contains records for each address.
Your code used the type and creator for the app, but specified the name for
the data. These should match, if you're going to specify both. My code just
leaves out the LocalID, causing ExgDBWrite to find the database based on the
name only.
> I get following in dataR...
> AddressBookcodetFRM�tAIB�tFRM
I don't think you understand what ExgDBWrite produces. See the Palm File
Format Spec document for the file format. The first 32 bytes contain the
database name, then there are 2 bytes for the database attributes, etc. This
is not a text-based format.
--
Danny @ PalmSource
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/support/forums/