Hi All,

I'm trying write an application which can copy an existing file (PRC or PDB)
in a Palm device.
Here I'm using Beaming technology used in Palm OS, namely ExgDBRead, and
ExgDBWrite.
Although this technology is used, the app will be run in a single device. I
found that this would be the easiest method to read a file since I do not
know the record structure of the file to be copied.

but there seems to be a problem with the code I written.

what I do is first read the file using ExgDBWrite and write to a database in
device.
code is as follows.

....
....
// write the file to a Temp Database
Err xx1 =  ExgDBWrite (WriteDatabase, NULL, dbName, NULL, 0);

LocalID dbID;
UInt16 cardNo = 0;
Boolean needReset = false;
Boolean keepDates;
recCount = 0;

// read from the Temp Database and create a new file
error = ExgDBRead(ReadDatabase, NULL, NULL, &dbID, cardNo, &needReset,
keepDates);
....
....



Err WriteDatabase(const void *buffer, UInt32 *bytes, void *exgSocket)
{
        LocalID dbID;
        UInt16 cardNo = 0;
        Boolean needReset;
        Boolean keepDates;

        xxCount++;

        //change the creator ID and first character of the file type so it becomes
unique
        if (xxCount == 1)
        {
                *( (char*)buffer + 0) = 'Q';
                *( (char*)buffer + 60) = 'X';
                *( (char*)buffer + 61) = 'X';
                *( (char*)buffer + 62) = 'X';
                *( (char*)buffer + 63) = 'X';
                *( (char*)buffer + 64) = 'X';
        }

        void* rec;
        void* recP;

        UInt16 index = dmMaxRecordIndex;

        MemHandle mH = DmNewRecord( TempDB , &index , (*bytes));
        recP    = (void*) MemHandleLock( mH );
        rec = (void*)buffer;
        DmWrite( recP , 0 , rec, *bytes );

        MemHandleUnlock(mH);
        DmReleaseRecord(TempDB , index , true );

        return errNone;
}


Err ReadDatabase(void* dataP, UInt32* sizeP, void* userDataP)
{
        MemHandle recordH =DmQueryRecord(TempDB,recCount);
        void *rrr =(void*)MemHandleLock(recordH);
        dataP = rrr;
        *sizeP = MemHandleSize( recordH );
        dataP = MemPtrNew( *sizeP );

        for( int i = 0 ; i < *sizeP ; i++ )
                *( (UInt8*) dataP + i ) = *( (UInt8*) rrr + i );

        recCount++;
        MemHandleUnlock(recordH);

        return errNone;
}

It seems writing to the database part (ExgDBWrite) is OK. I checked the Temp
Database from another app (Insider) and it showed as 10 records written to
that Temp Database (the original PDB file i used contained 3 data records.
so in addition to this 3 records there were 7 more short records including
the header information).

When i ExgDBRead, the call back function (ReadDatabase) executes a random
number of times (most of the time 4 times). why is that ? i guess the call
back function should be run 10 times. Am i correct ?

someone pls help me to over come this problem.

thanks for reading this long description.

Merry X'mas to u all.

Dil �





_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/tech/support/forums/

Reply via email to