I'm not sure what might be going on with your UInt.  If it is declared in a
header which is included in multiple source files (one for Form1 and one for
Form2, there could be two different (local) globals under the same name.  I
would check its address to verify/eliminate this possibility.  A second
possibility is that flaky CodeWarrior is simply mis-reporting its value.  A
third possibility is that your application is running in a context where it
doesn't have access to globals, though if this is the cause, I would expect
it to crash rather than give the symptoms that you report.

A second (possibly relevant) point is that if you are attempting to save a
locked pointer to a field and the field still has a handle to that memory,
the field will free that memory on form close, invalidating the pointer.  In
general, when getting data out of a field and attempting to retain it, you
should get the field's handle and then reset the field's handle to NULL so
that the field will no longer muck with the (just-extracted) data.  Of
course, an alternate strategy that will work is to copy the field's data
into separate storage that you maintain.

-bob mckenzie, palm pdx

-----Original Message-----
From: Sandra Webb [mailto:[EMAIL PROTECTED]]
Sent: Monday, November 26, 2001 10:34 AM
To: Palm Developer Forum
Subject: Unknown Variable Reset


Problem:
For some unknown reason, my variable is resetting even though I did not tell
it to.

Background:
What I am doing is sending information from one form to another.  Form1 is a
search form where you enter a text string and select a type of search (which
field to search by).  Form2 is a results form where you can iterate through
the results of the search.

Method Used:
What I did was I created two variables (declared in form1's header), a
CharPtr and a UInt.  I did a MemHandleLock on the search text field and set
that to the CharPtr and I set the UInt to be either 0, 1, or 2 (#defines for
each field type).  Then I opened Form2 using FrmGotoForm.  (I do release the
MemHandleLock, but only after I am done using it ... at the end of form2).
The only other place where the UInt is changed is in the Form1Init Function
(which is called on the form1 frmOpen event... it is changed to zero).

Testing:
During my test: the UInt is = 2 in form1, however when I get to where I use
it in Form2, it is 0.  I'm not sure of the value of the CharPtr (i can't
figure out how to set a watch), however when it comes to doing an "StrStr"
on the CharPtr it crashes my program so I must assume it isn't the correct
value either. (one wierd thing is that it doesn't crash on the first use of
StrStr, but on the second.)

Can anyone please help me figure out what I am doing wrong here?  Thank you
very much in advance for any help you can give.

Sandra Webb



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

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

Reply via email to