Page 1 of 1

TWbrowse and ordscope function

Posted: Tue Jun 13, 2006 12:32 pm
by pawelu
Antonio,

I create TWbrowse control based on database with ordscope function (sample below). TWbrose have about 7 row, filtered database - 3. When user move vertical scrollbar at the end of scale current record is diplayed standalone at the end of control. How to filter database properly with ordscope function ?

Regards
Pawel

Code: Select all

Function Brw ()

   Local oWnd := Nil
   Local oBrw := Nil
   Local aStr := {}

   InitEnv ()

   FErase ('Brw' + IndexExt ())
   AAdd (aStr, {'F1', 'C', 10, 0})
   AAdd (aStr, {'F2', 'N',  5, 0})
   DbCreate ('Brw', aStr)
   Use Brw New
   Index On Brw->F1 Tag Brw To Brw

   For i := 1 To 100
       Brw->(DbAppend ())
       If i % 31 == 0
          Brw->F1 := 'A' + PadL (i, 3, '0')
       Else
          Brw->F1 := 'B' + PadL (i, 3, '0')
       Endif  
       Brw->F2 := i
   Next   
   Brw->(DbGoTop ())
   Brw->(OrdScope (0, 'A'))
   Brw->(OrdScope (1, 'A'))
   Brw->(DbSeek ('A'))

   Define Window oWnd Title 'Test'
   @  39,  0 ListBox oBrw ;
   Fields ;
   Brw->F1, ;
   TransForm (Brw->F2, '999') ;
   Alias 'Brw' ;
   FieldSizes 100, 100 ;
   Header 'F1', 'F2' ;
   Size 240, 148 ;
   Pixel
   Activate Window oWnd

   Brw->(DbCloseArea ()) 
   FErase ('Brw' + IndexExt ())

Return .T.

Function InitEnv ()

   Request DbfCdx
   Request DbfFpt
   RddSetDefault ('DbfCdx')
   Request Hb_Lang_PL852
   Request Hb_Lang_PLWIN
   Request Hb_CodePage_PL852
   Request Hb_CodePage_PLWIN

   Set Century On
   Set Epoch To 1995
   Set Date German
   Set Deleted On
   Hb_LangSelect ('PL')
   Hb_SetCodePage ('PLWIN')

Return .T.
Image

Posted: Tue Jun 13, 2006 9:10 pm
by Antonio Linares
Pawel,

You need to properly set <oBrowse>:bLogicLen DATA so the browse knows how many records is managing:

oBrw:bLogicLen = { || Brw->( OrdKeyCount() ) }