Hy all!

Does anybody know which is the best way to fill a list with a lot of itens?

First of all, i tried to use a pointer to store all my itens, like the code
below





Char **itemList;
UInt16 LoadProdutos()
{

MemHandle h;
UInt16 RecNum, Cont;
Char *CodProd, *Descricao;


//Abre o banco de dados
OpenDatabase(&dbPtrF, "SAF_PRODUTOS");


//Busca a quantidade de produtos
RecNum = DmNumRecords(dbPtrF);

//Realoca a quantidade de memoria usada pela lista
itemList = (Char **)MemPtrNew(RecNum * 60 * sizeof(Char **));

for (Cont =0; Cont < RecNum; Cont ++)
{

h = DmQueryRecord(dbPtrF, Cont);
CodProd = (Char *)MemHandleLock(h);
ForwardColumnsOnRecord(CodProd, &Descricao, 1);
MemHandleUnlock(h);

itemList[Cont] = (Char *)MemPtrNew(StrLen(Descricao) * sizeof(Char *));
StrCopy(itemList[Cont], Descricao);

}

DmCloseDatabase(dbPtrF);
return RecNum;

}


But on the 36st item, the programm crashes, and the emulator said that it
executed an unknow ou illegal code machine instruction.

After, i initialized the pointer like this
Char *itemList[3000];

and copy the content of the pointer 'DESCRICAO' into the pointer
itemList[Cont]. Now, it works, but, the list need about 4 secs to be loaded,
and i know that the way that i used to declare the pointer wasn't good,
because of the lot of memory that the pointer need to exist.

Now, i thinking about load only the itens that a need and, i will continue
loading the list when the user scroll that.

Does anybody suggest any better way to work with a list of this size?

Thanks all!




Régis Daniel de Oliveira



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

Reply via email to