Hi, folks.
I'm experimenting with a setup that I suppose to work if I understand
the Palm API correctly.
I have a database record that has some static fields at the beginning
(totaling 6 bytes). After this are 7 0-terminated strings. Initially
(i.e. after creation of the record), all strings are empty.
I wrote a function that locks a handle on that record and stores the
offset to each string together with the handle in a struct. Later, I
assign the unlocked handle together with the different offsets to a
Field with FldSetText. For doing so, I wrote a small function that
determins the length of the string and puts everything in place:
void FldSetHandleID(UInt16 id, MemHandle h, UInt16 offset)
{
FieldPtr fld;
UInt16 len;
len = StrLenHandle(h, offset); // returns lenth of string at offset
fld = GetObjectPtr(id);
FldSetText(fld, h, offset, len+1);
FldSetMaxChars(fld, 20);
} /* FldSetHandleID */
Strangely, the whole thing does not work. To be more precise: contrary
to what's written in the API documentation, FldSetText does not resize
the record regardless of the parameters. It only resizes the record if I
only have /one/ string in the record assigned to a UI Field.
If I assign more strings to more UI Fields and set the number of
allocated bytes in FldSetText to 1 (because initially, the string only
consists of the terminator), I cannot enter any text at all. The Palm
says "The data storage of the handheld is full". If I set the number of
allocated strings to a higher value (say, n), n bytes are overwritten in
the record, scrambling the subsequent fields.
I know that this whole thing works with text fields in table objects, so
what's going wrong here? Is there any sample code that shows how to get
this done?
Matthias
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/support/forums/