Hi all,
        I have a search function that searches for name matches in a table, but I
have a problem in displaying the found records if the records in the table
exceeds the number of rows in the table. Here is the code snippet :

The following search function can only display the found records in the
specified
number of rows in the table, while the records displayed after scrolling
down the
table cannot be seen.

static void SearchRecord(char* outDest) {
UInt16  size = 50;
Boolean  match = false;
UInt32 outPos = 0;
UInt16 outLen;
Boolean test = false;
TableType* pTbl;
DRecord Rec;
unsigned long RecId;
unsigned short i;
FormPtr pFrm = FrmGetActiveForm();

TxtGluePrepFindString(SearchName, outDest, size);
pTbl = (TableType*) FrmGetObjectPtr(pFrm, FrmGetObjectIndex(pFrm,
CustomerDisplayTable));
CurrentTopRecId = 0;
TableRowCount = TblGetNumberOfRows(pTbl);

TableSetRowId(pTbl, TableRowCount , DB,CurrentTopRecId, &CurrentBotRecId,
CurrentCategory);

        for(i=0; i < DmNumRecords(DB); i++, CurrentTopRecId++) {
                RecId = DBRecordGetId(DB, i);
                CF_DBRecordRead(DB, &Rec, RecId);
                match = TxtFindString(Rec.Get(NAME), outDest, &outPos, &outLen);

                if(match) {
                        TblSetRowUsable (pTbl, i, true);
                }
                else {
                        TblSetRowUsable(pTbl,i, false);
                }
        }
        TblRedrawTable(pTbl);
}

void TableSetRowId(TableType* pTbl, unsigned short TotalRowCount, DmOpenRef
DB, unsigned short TopRecId, unsigned short* BotRecId, unsigned short
Category)
{
        MemHandle hRec;
        unsigned short Row;

        for (Row = 0; Row < TotalRowCount; Row++, TopRecId++)

                hRec = DmQueryNextInCategory(DB, &TopRecId, Category);
                if (hRec) {

                        TblSetItemInt (pTbl, Row, 0, TopRecId);
                        TblSetRowUsable (pTbl, Row, true);
                        *BotRecId = TopRecId;
                }
                else {
                        TblSetRowUsable(pTbl, Row, false);
                }
                TblMarkRowInvalid(pTbl, Row);
        }
}

        Any kind of input / ideas will help. Thank you so much.

Regards,
Edwin







-- 
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