FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour XBROWSE AUTOSORT dont work
Posts: 301
Joined: Fri Jun 01, 2007 09:07 AM
XBROWSE AUTOSORT dont work
Posted: Thu Mar 01, 2012 01:42 PM
Hi all
Please help or some sugestions.
In this sample AUTOSORT dont work
Code (fw): Select all Collapse
#include "FiveWin.Ch"
#include "ord.ch"
#include "xbrowse.ch"

//----------------------------------------------------------------------------//

REQUEST DBFCDX

//----------------------------------------------------------------------------//

function MyBrowse()

   local oDlg, oBrw, cAlias

   RddSetDefault("DBFCDX")

   USE TESTDBF  NEW SHARED

   SET ORDER TO TAG FIRST
   GO TOP

   DEFINE DIALOG oDlg SIZE 900,500

   cAlias := Alias()

   @ 32.5, 0 XBROWSE oBrw ;
            OF oDlg SIZE 400,200 PIXEL ;
            ALIAS cAlias ;
            AUTOCOLS AUTOSORT FOOTERS LINES CELL ;
            BACKGROUND 'STONE'

   oBrw:CreateFromCode()


   ACTIVATE DIALOG oDlg CENTERED

   (cAlias)->( dbCloseArea() )

return nil


If i use dbf file CUSTOMER in \fwh\samples folder going good
What that mean ?

Need i to create index file before defining XBROWSE ? And if yes how to create index file ?
BTW i really dont know the dbf file name becouse it is created from SQL select using TODBC and TDBODBCD classes
and i dont know the fieldnames.

Best Regards and again i please for fast sugestion.
Posts: 301
Joined: Fri Jun 01, 2007 09:07 AM
Re: XBROWSE AUTOSORT dont work
Posted: Fri Mar 02, 2012 02:47 PM

?

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: XBROWSE AUTOSORT dont work
Posted: Fri Mar 02, 2012 10:10 PM

AUTOSORT while browsing DBF files works only for columns where index exists in the corresponding index file opened in the workarea.

Regards



G. N. Rao.

Hyderabad, India
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: XBROWSE AUTOSORT dont work
Posted: Fri Mar 02, 2012 10:18 PM
In your case, the Alias() is known but you say you do not know the filename or field names. You can still use this function to create temporary index on all the fields. Add these functions to your code and call ( Alias() )->( CreateTempCdx() ) before creating xbrowse.

Code (fw): Select all Collapse
//----------------------------------------------------------------------------//

function CreateTempCdx()

   local n

   for n := 1 to FCount()
      CreateTempTag( FieldName( n ), FieldType( n ) )
   next

return nil

//----------------------------------------------------------------------------//

static function CreateTag( ctag, cType )

   PRIVATE cExpr

   if cType == 'C'
      cExpr    := "UPPER(" + Trim( cTag ) + ")"
      INDEX ON &cExpr TAG &cTag TO TEMP TEMPORARY
   else
      INDEX ON &ctag TAG &ctag TO TEMP TEMPORARY
   endif

return nil

//----------------------------------------------------------------------------//
Regards



G. N. Rao.

Hyderabad, India

Continue the discussion