I can't use offsetof() in my application.  My StructType is defined as
typedef struct {
UInt32  Id1;
UInt32 Id2;
char     Data[1];
} StructType;

I can use offsetof(StructType, Id1) to write to the first field, but how can I
update data in the 5th field (also have to consider there is also data in the
sixth field and new data might have a different size)?

-Elizabeth


|--------+----------------------->
|        |          rishib@lisco.|
|        |          com          |
|        |                       |
|        |          10/02/00     |
|        |          04:47 PM     |
|        |          Please       |
|        |          respond to   |
|        |          palm-dev-foru|
|        |          m            |
|        |                       |
|--------+----------------------->
  >-----------------------------------------------------------|
  |                                                           |
  |       To:     [EMAIL PROTECTED]              |
  |       cc:                                                 |
  |       Subject:     Re: How to update a specified field in |
  |       the database                                        |
  >-----------------------------------------------------------|






From: <[EMAIL PROTECTED]>
Subject: How to update a specified field in the database

> Can someone give me some direction on updated a specific field in the
database
> for a giving field position, data to be written to the record, and the
record
> handle?  I already know how to write data to the database record by
record, but
> I sometimes need to update just some specified field(s) in the record.
Thanks.

>From Neil Rhodes' book (available online at
http://www.palmos.com/dev/tech/docs/devguide/ch06.htm#P218_13516):

VoidHand myRecord = DmGetRecord(gDB, recordNumber);
StructType *s = MemHandleLock(myRecord);

DmWrite(s, offsetof(StructType, field), &newValue, sizeof(newValue));
MemHandleUnlock(myRecord);
DmReleaseRecord(gDB, recordNumber, true);



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




-- 
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