When I execute the following, the Text field of the record is filled
with garbage. I've looked all over to find a possible solution, but
haven't found anything.
Do I need to pack the record (a la Palm Prog. the Definitive) even
though there's a single string field?
Any help is much appreciated.
Mark
// begin code snippet
typedef struct
{
long OrderNumber;
short Type; // the types defined below
CharPtr Text;
} NotesRecord;
Boolean NoteWriteRecord(long order, short type, const Char* pText){
UInt length = 0;
UInt offset = 0;
Handle hRec;
NotesRecord *ptr;
Err error;
int index = NoteGetIndexByApptType(order, type);
length = sizeof(order) + sizeof(type) + StrLen(pText) + 1; // null term
if (index > -1) { // get a handle to the record
hRec = DmResizeRecord(gNotesDB, index, length);
} else { // create a new record
index = 0;
hRec = DmNewRecord(gNotesDB, (UInt *)&index, length);
}
// write the data to the record
if (hRec) {
ptr = (NotesRecord *)MemHandleLock(hRec);
DmWrite(ptr, offset, &order, sizeof(order));
offset += sizeof(order);
DmWrite(ptr, offset, &type, sizeof(type));
offset += sizeof(type);
error = DmStrCopy(ptr, offset,(CharPtr)pText);
MemHandleUnlock(hRec);
return true;
} else {
// non-fatal display the error
return false;
}
// release the record
NoteReleaseRecord(index, true);
}
--
Mark W. Alme
Analyst
Alme & Associates
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/