Luck has absolutely nothing to do with it.

To be able to safely dynamically write to a label, I take the following precautions
1) Put enough spaces in the initial label declaration to fill it out to a minimum of 12 characters
2) Use a "gatekeeper" function to change the label which ensures that the new string is never longer than 10 characters.
3) Don't change labels without going through this "gatekeeper" function.
4) When I need a longer text for a label, I use the alternative pointer method, but ensure I'm using a string that exists for the life of the form.


Note: The "10" limit works very well for me, but might not be the right maximum size for all.

Roger Stringer


Subject: Re: Re[2]: Dynamically rewriting a label
From: "Dave Lippincott" <[EMAIL PROTECTED]>
Date: Thu, 14 Oct 2004 09:18:16 -0400

You've been lucky.  I had problems in past apps when modifying labels.  If
you keep the new text to the same size or smaller then what was specified in
the resource editor, it should work.  If you are building the new text
string based on inputs from the running app, make sure to test the string
length before stuffing into your label.
Its safer to use a read only edit field.

----- Original Message -----
From: "Martin Bruner" <[EMAIL PROTECTED]>
To: "Palm Developer Forum" <[EMAIL PROTECTED]>
Sent: Wednesday, October 13, 2004 6:24 PM
Subject: RE: Re[2]: Dynamically rewriting a label


> So far in my dozen or so released applications, this method has produced no > problems. > > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] Behalf Of Adrien > Regimbald > Sent: Wednesday, October 13, 2004 3:55 PM > To: Palm Developer Forum > Subject: Re[2]: Dynamically rewriting a label > > > Unfortunately, this is an error prone method. Modifying label text > introduces ugly issues: > > * If you copy a "static string" to the label, you will have problems > if the new string is longer than the text you put on the label within > the original resource > * If you copy a string variable to the label, you will need to ensure > that the variable doesn't go out of scope. In C++, this isn't too bad > with a class variable, but in C, you end up introducing undesirable > global variables for every label


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

Reply via email to