In your project settings, under Code Generation - Global Optimizations, make
sure optimizations are turned off, or set low, if you want to debug. The
compiler will optimize your code below so that you cannot stop on the if
statement.
The compiler also optimizes your variables and will use the same space for
several if they have different scopes. For example, when your program is
using the variable catSelected, it does not need selectedIndex (at least in
the snippet you provided) so they will probably have the same value in the
debugger.
Regards,
Steve
-----Original Message-----
From: Jeff Allen [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, May 10, 2000 2:36 PM
To: Palm Developer Forum
Subject: Variable Problems
Here's a small snipit of the code that I'm having a problem with:
----------------------------------------------------------------------------
--------------------
static void UpdateList(Word selectedRecord)
{
FormPtr pFrm = FrmGetFormPtr(MarksForm);
ListPtr pLst = (ListPtr)GetObjectPtr(MarksTitleList);
ListPtr pCatList = (ListPtr)GetObjectPtr(MarksCategoriesList);
RectangleType lstRect;
Int lstWidth, textLen, i, j, choicesOffset = 0;
CharPtr choices;
Word selectedIndex = -1, catSelected;
VoidHand recHandle;
Err error;
UInt theCategory, recordNum = 0, totalItems, displayedItems = 0;
Boolean fits;
CharPtr pTitle = 0;
catSelected = LstGetSelection(pCatList);
if (catSelected > 1)
{
theCategory = CategoryFind(gDBHandle,
LstGetSelectionText(pCatList,
catSelected));
} else {
theCategory = dmAllCategories;
}
[remaining code omitted]
----------------------------------------------------------------------------
--------------------
Now the problem is happening with the line: if (catSelected > 1)
Common sense tells me that if catSelected == 3, then (3 > 1) is true, so
this expression should evaluate as true. It doesn't. Ever. When I run it
through the debugger, it doesn't even stop on the if statement, it just
skips down to the else block. One other strange thing that I noticed while
watching the debugger. When catSelected is assigned, these variables:
error
displayedItems
selectedIndex
all get set to the exact same value, for no apparent reason. I'm certain
these two issues are related, but I can't for the life of me imagine why
this would be happening. Any ideas?
-Jeff
--
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/