Here's one way:

Word foundCat;
Word numCats = 0;
Char seekCat[dmCategoryLength];

for (foundCat = 0; foundCat < dmRecNumCategories; foundCat++) {
        CategoryGetName (theDB, foundCat, seekCat);
        if (seekCat[0] != '\0')
                numCats++;
}

It just gets the category name of each potential category... if no category
is set in a given slot, CategoryGetName returns a null string. After running
this, numCats is set to the number of categories in the database. If you
want to hit the AppInfo block directly, you can just get it from the
database and then iterate over the categoryLabels array. That might be a tad
bit faster.

Re the other question, I'm guessing that there was an idea at some point
that a category position in the categoryLabels array was not the same as the
category unique id as used in a record. That would allow for rearranging the
categoryLabels array without needing to update all the category values in
all the filed records. Just a guess

John Schettino
Palm OS Programming for Dummies: http://schettino.tripod.com

-----Original Message-----
From: Paul Taylor [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, March 22, 2000 9:57 PM
To: Palm Developer Forum
Subject: Number of Categories in a database


Hi all,

    This is probably an easy question, but I've not yet found an easy way to
do it... Does anyone know of a way to find the total number of categories
that are in a particular database?  Is there some function call that I've
overlooked?  Or has someone already written an easily portable function to
accomplish this?

    Or have I just really overlooked something that's extremely easy?

Paul Taylor
[EMAIL PROTECTED]


-- 
For information on using the Palm Developer Forums, or to unsubscribe,
please see http://www.palm.com/devzone/mailinglists.html

-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palm.com/devzone/mailinglists.html

Reply via email to