This method seams to be workable but things go a little complicated when we 
must deal with many fields ..
we can use an alternative method to this when there are too many fields to deal 
with. It makes easier even if we change the sizes of the fields...
------------------------------------------------
typedef struct
{
        UInt16 iMember;
        char    strMember[10];
}Record;

void someWriteFun(UInt16 i, char *s)
{
        UInt16 recIndex = dmMaxRecordIndex;
        Record *rec ;
        MemHandle *memH = DmNewRecord(dmRef, &recIndex, sizeof(Record));
        if(memH)
        {
                rec = (Record*) MemHandleLock(memH);
                DmWrite(rec, OffSetOf(Record, strMember), s , StrLen(s)));
                .
                .
                .
                .
        }
}

void someReadFun(UInt16 recIndex, Record *retRec)
{
        Record *rec ;
        MemHandle *memH = DmGetRecord(dmRef, recIndex);
        if(memH)
        {
                rec = (Record*) MemHandleLock(memH);
                if(rec) *recRec = *rec;
                MemHandleUnlock(memH);
        }
}

void MyOtherUsableFun()
{
        ...
        Record rec
        someReadFun(recIndex, &rec);
        
        *USE* rec.iMember       
        *USE* rec.strMember
        ...
}
------------------------------------------------------------------------------------
> I finally got it working.
> 
> I created a pointer to a char(1byte), that holds the position in 
> memory I want to read.


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

Reply via email to