Greetings

I use Sybase Ultralite, PalmOS 3.1 (oh yes..:-( )

My problem is:

I have to place a lot of lines into poptrigger list, but I don't
know how many items I have. Items are from database and counting
them before in simle loop will take about 20-25 seconds. Counting
with select count() is about 15-20 seconds, so unusable too. 
Number of items can be between 800-900.

I made my owner draw function (follows)

Distributor_Select *distrib; 
// it is a big class generated by ultralite generator from huge
// query (so Next() and Previous() are slow...)
int SS_lastrow;                          
// here I have last drawn item so I don't have to always do 
// 'distrib->First();for(a=0;a<itemNum;a++) distrib->Next();'
// which is very sloooow



//List is initialized with 9999 items at the beggining
void WriteToDeDistributor (Int16 itemNum,RectangleType *bounds, Char **itemsText)
{
  bool ok;
  int a;
  FormType *frmP;
  ListType *lstP;
  RectangleType r;
  int temp;
  
  WinEraseRectangle(bounds,1);                  
  frmP=FrmGetFormPtr(DetailsForm);  //FrmGetActiveForm returns NULL
  lstP=(ListType *)GetObjectPtr(frmP,DetailsDistributorList);

  if(itemNum==0) 
  {
    ok=distrib->First();
    a=0;
  }
  if(SS_lastrow<itemNum)
  {
    ok=true;    
    for(a=SS_lastrow;a<itemNum && ok==true;a++) 
    {
      ok=distrib->Next();
      if(ok==false)
      {
        distrib->Previous();
        a--;
      }
    }  
  }
  else if(SS_lastrow>itemNum)
  {      
    ok=true;
    for(a=SS_lastrow;a>itemNum;a--) 
      distrib->Previous();
  }      
  SS_lastrow=a;

//until now it was only begginng, now real things begin

  if(ok==false)
  {
    //if I cannot find wanted item it doesn't exist
    FrmGetObjectBounds(frmP,FrmGetObjectIndex(frmP,DetailsDistributorList),&r);
    temp=(r.topLeft.y+r.extent.y)-(bounds->topLeft.y+bounds->extent.y);
    if(temp<bounds->extent.y)
    {
      //if I am on the last itemline, update all wanted attributes and redraw list
      //it must be only for last item, otherwise I will get infinite loop
      LstSetListChoices(lstP,NULL,a+1);
      LstSetTopItem(lstP,a);
      LstDrawList(lstP);
    }  
  }
  else
  {
    distrib->LoadData();
    MyWinDrawChars(distrib->cus_name, bounds->extent.x, bounds->topLeft.x, 
bounds->topLeft.y, false);
    //it is only WinDrawChars but a bit enhanced
  }  
}

Problem is, that everything works until I scroll to the end of list using hardware 
pgdown key. Then it will redraw list, but hardware pgup/pgdown doesn't work, only
possibility to scroll is by dragging the pen inside. But all presses of pgup are
remembered and will apply when I will open the list next time.

Also when I scroll by dragging and reach the end of list, it will be redrawn, but I 
believe this is some my silly bug.

Please help, customers have too much data in their databases and they really don't
like to wait each time they enter some screens.


For people who don't know ultralite:

It is not possible to get a number of items in result, only possibilities to get it is
  1) another query with count() (but internally it is possibility no.2 )
  2) do own loop and count it 
       ok=First();
       if(ok==false)
         count=0;
       else
       {
         count=1;
         while(Next()==false)
           count++;
       }

     of course, very complex queries (specially with ORDER BY) have too slow 
functions...
      
It is not possible to go to wanted item in result, you can use only Next(), Previous(),
  First(), Last(), but Last() uses Next() internally anyway (I am not sure, but I 
checked
  how log it takes...)

If you think I am stupid and there is any simple way how to make all this stuff run in
lightspeed, please let me know and you have free beer when we will meet.


Please help.

Bye



         
    




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