>
> I'd been watching the list to see the response to your question. I
haven't
> attacked this myself recently, but I was having a similar problem once
> before. Could you share your revelation? Thanks...
>
Well, it was much easier than I thought... I was on the right track with
AppInfoPtr...
Actually, I had a book that gave me the final hint.. Glenn Bachmanns "Palm
Programming".. I'd recommend it to anyone.. Also, "Palm OS Programming for
Dummies" is a great book if you aren't already too advanced.. It lays
things out in a very easy to understand way.. I found that after reading
through it, I understood several things that were murky before.
Anyhow, here's the code segment that I ended up using:
(Please excuse the crudeness of my code - I got this working like I wanted
last night about
5 AM)
// This function should put the current Category list in
// TextCatList[x].Name
void GenerateCategoryList (void)
{
int counter=0;
Word totalCategories = 0;
CharPtr string, string2 = ""; // These 2 strings are purely for checks
AddrAppInfoPtr appInfoPtr;
appInfoPtr = (AddrAppInfoPtr) AddrAppInfoGetPtr(AddrDB);
ErrFatalDisplayIf(appInfoPtr == NULL, "Missing app info block");
StrCopy(string, "Unfiled");
for (counter = 0; counter < 16; counter++)
{
// Below line gets the name of the category and stores it in
TextCatList
StrCopy(TextCatList[totalCategories].Name,
appInfoPtr->categoryLabels[counter]);
// Below line gets the index of the category and stores it also
TextCatList[totalCategories].index = CategoryFind (AddrDB,
TextCatList[counter].Name);
if (((StrCompare(TextCatList[totalCategories].Name, string)) == 0) ||
((StrCompare(TextCatList[totalCategories].Name, string2)) == 0))
totalCategories--;
// Above lines consider the category "Unfiled" or none, and remove one
// from the totalCategories variable.
totalCategories++;
// Above increments totalCategories
}
// Below updates my global variable
CatListTotal = totalCategories;
// My routine to sort the list of categories
SortCatList();
// Release the appInfoPtr
MemPtrUnlock(appInfoPtr);
}
Again, it's not the best code, I'm sure... Also forgive the use of
globals... I'm almost afraid to post it, as it's likely to be criticed
heavily...but here it is for posterity... : )