Since your database is small 7 records with 6 characters each (42 
bytes total), why not keep the record size constant at 6 bytes?  
You're not going to save a lot of memory by resizing the records each 
time they are changed.

The method that you are presently using works great for large 
variations in the amount of text in a record (for example an entry in 
the Memo app could be several paragraphs of text or a single 
character).  Here you would definetly not want to have fixed size 
records.  If you still would like to stick with the variable record 
size, you could checkout the code for the Memo application, but it'll 
be much easier to keep your records fixed.

You could even keep all of the strings in a single record if you know 
that there will only be 7 strings.  Easier yet, how about keeping 
these strings in the application prefrence database?

--- In [EMAIL PROTECTED], Matthias Jordan <[EMAIL PROTECTED]> 
wrote:
> 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/


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

Reply via email to