XBrowse's built-in incremental seek functionality is very good. But in case of Arrays this functionality works perfectly
only when the Array columns are set sequentially from columns 1,2,3 ... The logic fails when the order of the columns is not sequential.
I propose this sample code to address Mr. Tim's problem:
#include "FiveWin.Ch"
#include "xbrowse.ch"
//------------------------------------------------------------------//
function Main()
local oDlg, oBrw
local aData := { ;
{ 4578, 'Sales', 'B012' }, ;
{ 234, 'Purchaes', 'B342' }, ;
{ 75, 'Wages', 'C567' }, ;
{ 1435, 'Freight', 'C203' } }
DEFINE DIALOG oDlg SIZE 440,240 PIXEL
@ 10,10 XBROWSE oBrw SIZE 200,100 PIXEL OF oDlg ;
COLUMNS 3, 2, 1 ;
HEADERS 'Account', 'Description', 'D/C' ;
COLSIZES 80,150,80 ;
ARRAY aData ;
AUTOSORT ;
ON DBLCLICK ( MsgInfo( oBrw:aRow[ 3 ] ), oDlg:End() )
// Note: oBrw:aRow is shortcut for oBrw:aArrayData[oBrw]
oBrw:nStretchCol := 2
// Following three lines are needed till XBrowse is rectified
oBrw:aCols[ 1 ]:cOrder := 'D'
oBrw:aCols[ 1 ]:SetOrder()
oBrw:bSeek := { |c| ArrayIncrSeek( oBrw, aData, c ) }
// < .. other browse settings .. >
oBrw:CreateFromCode()
ACTIVATE DIALOG oDlg CENTERED
return ( 0 )
//------------------------------------------------------------------//
function ArrayIncrSeek( oBrw, aData, cSeek )
local nRow, nCol
local cVal
if ( nCol := AScan( oBrw:aCols, { |oCol| ! Empty( oCol:cOrder ) } ) ) > 0
// following line is ommitted in TXBrowse source code
nCol := oBrw:aCols[ nCol ]:nArrayCol
cSeek := Upper( cSeek )
for nRow := 1 to Len( aData )
if Upper( cValToChar( aData[ nRow ][ nCol ] ) ) = cSeek // non-exact =
oBrw:nArrayAt := nRow
return .t.
endif
next nRow
endif
return .f.
//------------------------------------------------------------------//
This code may be compiled to see that now the incremental seek works. After verifying, Mr. Tim may please add his specific functionality.
The above incremental seek function can be used generally for all array browses where the columns are not sequential.
If Mr. Antonio permits, I shall separately communicate my proposed fixes to the XBrowse code.