[EMAIL PROTECTED] wrote in message <26058@palm-dev-forum>...
>
>
>
>I was trying to write the whole record with updates before and failed. The
>problem is in the update data. If the sizes of old and new data are the
same,
>no problem. If old data size is bigger, it erases data from the following
>field.
>
>Attached is some code in my application to handle the update. I checked
the
>content of rec after line3 and it was unpacking correctly with
rec.Data[attrPos]
>= "Y" and rec.Data[attrPos + 1] = "Y". Then I assign value in newChoice
("NA")
>to rec.Data[attrPos] and tried to save it. I checked again after line7 and
>found that data in rec.Data[attrPos] = "". Both my Pack and Unpack
functions
>don't change values in rec. Thanks.
>
>
>MemHandle h;
>FrpAdmin rec;
>FrpAdminPacked* packed;
>char* newChoice;
>UInt16 attrPos;
>
>h = DBRetrieveByFrpId(gFrpIdSelected, FRPADMIN, &recordIndex);
file://line1
>packed = (FrpAdminPacked*) MemHandleLock(h); file://line2
>UnpackFrpAdmin(&rec, packed); file://line3
>rec.Data[attrPos] = newChoice;
file://line4
>MemHandleUnlock(h); file://line5
>h = DBRetrieveByFrpId(gFrpIdSelected, FRPADMIN, &recordIndex);
file://line6
>PackFrpAdmin(&rec, h); file://line7
>
We'd have to see PackFrpAdmin() here to see how that's being handled.
Wait a sec ... if the -old- data is larger you have the problem? I would
expect problems if the -new- data is larger ...
Could you give an actual example of the corruption that is occurring?
Have you tried stepping through your packing routine in POSE to
watch the data change?
>
>[EMAIL PROTECTED] wrote in message <26052@palm-dev-forum>...
>>
>>
>>
>>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)?
>>
>
>You can't. In a situation such as you describe it's better just to
>read & write the whole record w/ paired pack() and unpack()
>routines.
>
>
--
-Richard M. Hartman
[EMAIL PROTECTED]
186,000 mi/sec: not just a good idea, it's the LAW!
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/