Hi!
Could anybody please help me with this code?
I've been trying to fix the problem for 2 days, but didn't succeed..
I have a structure defined as follows:
typedef struct {
UInt32 id;
Boolean selected;
VeranstaltungDateTimeType date;
const char *titel;
const char *location;
}Veranstaltung;
I would like to change the titel which is a text field, but I'm always
getting error messages: "Error with DmWriteCheck"
That's the code (based on the ToDo-example)
the new titel is saved in new_titelText.
recordH = DmQueryRecord(db, recordNum);
recordP = (Veranstaltung*) MemHandleLock(recordH)
// Calculate the size of the changed record. First,
// find the size of the data used from the old record.
newSize = sizeof (UInt32) + 1 + sizeof(Boolean) + 1 +
sizeof(VeranstaltungDateTimeType) + 1;
newSize += StrLen((Char *) neu_titelText) + 1;
newSize += StrLen(recordP->location) + 1;
// If the new description is longer, expand the record.
curSize = MemPtrSize (recordP);
// The interesting part is that even when I'm just adding one
character to the title,
// the newSize is about 94, when the curSize is about 24...
if (newSize > curSize)
{
MemPtrUnlock (recordP);
err = MemHandleResize (recordH, newSize);
recordP = (Veranstaltung*) MemHandleLock (recordH);
}
// Move the location field.
offset = sizeof(UInt32) + sizeof(Boolean) +
sizeof(VeranstaltungDateTimeType)
+ 1 + StrLen (neu_titelText) + 1;
c = recordP->titel;
c += StrLen(c) + 1;
DmWrite (recordP, offset, c, StrLen(c) + 1);
// Write the new titel field.
offset = sizeof(UInt32) + sizeof(Boolean) +
sizeof(VeranstaltungDateTimeType) + 1;
DmStrCopy (recordP, offset, neu_titelText);
// If the new description is shorter, shrink the record.
if (newSize < curSize)
MemHandleResize (recordH, newSize);
Does anybody have any idea why this code doesn't work and
why the newSize is much more than the curSize even if I'm just
changing some characters???
Many many thanks,
Dyk
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/support/forums/