--- Low Pui Kuen wrote:
>
> Err AddModule(Char *Mod)
> {
> MemHandle h;
> void *ptr;
>
> Err err = OpenDB();
For the moment, I'll assume that this correctly opens an existing
database (or creates it) and sets a global DmOpenRef, dbPtr.
> if (err)
> return err;
> else
> {
> Int16 Index = dmMaxRecordIndex; //Get the max record
> int size = StrLen(Mod);
> h = DmNewRecord(dbPtr,&Index,sizeof(size + 1));
This will not work.
First, Index should be UInt16, not Int16.
Second, the third argument to DmNewRecord must be the size of the
record you want to create. You want to create a record that is
StrLen(Mod) + 1 bytes, NOT sizeof(StrLen(Mod)+1) bytes.
> if(!h)
> return 1;
> else
> {
> ptr = MemHandleLock(h);
> DmWrite(ptr, 0 ,(const void *)&Mod , sizeof (size + 1)
);
This won't work, either.
First, Mod is a (Char *), so you should not use & in front of it.
Second, sizeof is wrong for the fourth argument. Use (size+1)
> DmReleaseRecord(dbPtr,Index,true);
> MemHandleUnlock(h);
> }
> }
> return 0;
> }
__________________________________________________
Do You Yahoo!?
Great stuff seeking new owners in Yahoo! Auctions!
http://auctions.yahoo.com
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/