There are questions, how to use CDX - Index as a filter
I have created the logic of this sample in my customer software
and it runs without problems in a network.
Code: Select all
// get your EXE-path
// ------------------------
c_dir := GetModuleFilename(GetInstance(),"SOFTWARE.EXE" + CHR(0), 255)
c_path := left ( c_dir, rat( "\", c_dir) -1 )
// For Filter-Index use 1-4 Caracter from the Username
// You can store the Var in your user LOGIN-DBF ( Passwords )
// Every user got 4 ( or more ) caracters to create his own Filter-Index
// -------------------------------------------------------------------------
cINDEXPART := substr(WNetGetUser(),1,4) // NAME
// the user creates a Private Filter-Index
// -------------------------------------------------
cPRIVIND1 := "SF1_" + cINDEXPART
// The index will be SF1_NAME
// looks in CDX-Compound index, if there is a old index
// when found destroys it
// --------------------------------------------------------------------
DBSELECTAREA(1)
// the CDX-Index is open, when you select the database
IF !empty( ORDNAME( ORDNUMBER("&cPRIVIND1") ) )
ORDDESTROY( ORDNUMBER("&cPRIVIND1") )
ENDIF
// creates a new Filter-Index
// The index will be at the end of the compound-Index
// ------------------------------------------------------------------
// Here you have to create a FOR-Index
// In this sample, the Index includes all Names with beginning "A"
ORDCREATE( ,"&cPRIVIND1",'SUBSTR(LOWER(Name) = "A"', ;
{|| SUBSTR(LOWER(Name) = "A" } , .F. )
// Set aktiv order to Filter-index
// -------------------------------------
DBSELECTAREA(1)
// If you want to use the filter-index ( .T. )
IF filterset = .f.
// Without Filter normal Index
// ----------------------------------
DBSETORDER(1)
ELSE
// Look for the Position of the filter-index
// in the compound-Index, because in the meantime,
// another user could add a index
// ----------------------------------------------------------
DBSETORDER(ORDNUMBER("&cPRIVIND1"))
ENDIF
// here the private- Index will be inside the Index with the
// same name like the database
// Sample CUSTOMER.CDX can have
// CUST1, CUST2, CUST3 and SF1_NAME
//
// SF1_NAME will be your PRIVAT-INDEX on Position 4
//
// There is another way, how to do it
// --------------------------------------
cNEWINDEX := c_path +"\SF1_" + cINDEXPART + ".CDX"
// extra CDX-File = SF1_NAME.CDX
ORDCREATE( "&cNEWINDEX","Test1","LOWER(Name)", ;
{|| LOWER(Name) } , .F. )
With that, you will have 2 CDX-Files
CUSTOMER.CDX and SF1_NAME.CDX
SF1_NAME.CDX will have the Index => Test1
When you want to use the same filter without changes
You have to open the Index with the name, because
the index is not included in the main-index
The index-files have different names, so there is no
problem in a network and it is very fast.
Uwe
[/code]