FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour A question about function FW_Cdxcreate()
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
A question about function FW_Cdxcreate()
Posted: Mon Feb 26, 2018 07:16 PM
Hello,

I wanted to create individual indexes for 7 files
before I used < FW_Cdxcreate() > :-)
everything works fine without problems
next I started to define extra indexes :-)
The solution returns < corrupt index >after restart
I saw that it is possible to define parameter in FW_Cdxcreate() :-)
Never before I had any problems creating indexfiles.

strange :-)
viewtopic.php?f=3&t=9931&p=48111&hilit=cdx+error+1012#p48111



With my external DBF-viewer I can open the file without problems
and the indexfiles are created.
NO problems using FW_Cdxcreate() :-)



Code (fw): Select all Collapse
        DBSELECTAREA(cFileName) // filenames from sample1 to 7
        FW_CdxCreate()

        ORDCREATE( ,"TOPICNO", "DESCEND( STR( TOPICNO ) )", ;
                {|| DESCEND(STR( TOPICNO ) ) } , .F. )  
        ORDCREATE( ,"FORUM","STR( FORUM )", ;
                {|| STR( FORUM ) } , .F. )  
        ORDCREATE( ,"DELETE","STR( T_DELETE )", ;
                {|| STR( T_DELETE ) } , .F. )  
        ORDCREATE( ,"DATE","DTOS( DATE )", ;
                {|| DTOS( DATE ) } , .F. )  
        ORDCREATE( ,"AUTHOR","AUTHOR + INFO1 + INFO2", ;
                {|| AUTHOR  + INFO1 + INFO2 } , .F. )
        ORDCREATE( ,"LIKE", "STR( LIKE ) + AUTHOR + INFO1 + INFO2 ) ", ;
                {|| STR( LIKE ) + AUTHOR + INFO1 + INFO2 } , .F. )      
        ORDCREATE( ,"INFO1","INFO1", ;
                {|| INFO1 } , .F. )         
        ORDCREATE( ,"INFO2","INFO2", ;
                {|| INFO2 } , .F. )


There is nothing special opening a dbf with my NETTOOLS

The errorline
-> 37 USE &cFileName ALIAS &cAlias NEW SHARED

Code (fw): Select all Collapse
FUNCTION NET_USE ( cFileName, cAlias, nTrials, nTime, lNet )
LOCAL lReturn  := .T.
LOCAL lOpen    := .F.

nTrcount   := nTrials
YesNo := .F.

// SHARED   all Users
// EXCLUSIVE  1 User

IF FILE( cFileName )
    nTrials := nTrcount
    DO WHILE !lOpen
        DO WHILE .T.
            IF !lNet
                USE &cFileName ALIAS &cAlias NEW EXCLUSIVE
            ELSE
                USE &cFileName ALIAS &cAlias NEW SHARED
            ENDIF
,,,
,,,


Any idea :-)
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: A question about function FW_Cdxcreate()
Posted: Mon Feb 26, 2018 08:00 PM
Maybe:

Code (fw): Select all Collapse
   FW_CdxCreate()

   CLOSE DATABASE

   USE SAMPLES EXCLUSIVE VIA "DBFCDX"  // or SHARED


Regards
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: A question about function FW_Cdxcreate()
Posted: Mon Feb 26, 2018 08:11 PM
Indexing 7 DBF's

FW_CdxCreate() // WORKS !!!

I tested index by index ALL numerics ( red ) don*t work !

//ORDCREATE( ,"TOPICNO", "DESCEND( STR( TOPICNO ) )", ;
// {|| DESCEND(STR( TOPICNO ) ) } , .F. )
//ORDCREATE( ,"FORUM","STR( FORUM )", ;
// {|| STR( FORUM ) } , .F. )
//ORDCREATE( ,"DELETE","STR( T_DELETE )", ;
// {|| STR( T_DELETE ) } , .F. )

ORDCREATE( ,"DATE","DTOS( DATE )", ;
{|| DTOS( DATE ) } , .F. )
ORDCREATE( ,"AUTHOR","AUTHOR + INFO1 + INFO2", ;
{|| AUTHOR + INFO1 + INFO2 } , .F. )

//ORDCREATE( ,"LIKE", "STR( LIKE ) + AUTHOR + INFO1 + INFO2 ) ", ;
// {|| STR( LIKE ) + AUTHOR + INFO1 + INFO2 } , .F. )

ORDCREATE( ,"INFO1","INFO1", ;
{|| INFO1 } , .F. )
ORDCREATE( ,"INFO2","INFO2", ;
{|| INFO2 } , .F. )


DBCREATE( c_path + cFilename + ".DBF", { ;
{ "TOPICNO", 'N', 6, 0 }, ; :-)
{ "LINK", 'C', 70, 0 }, ;
{ "TOPIC", 'C', 65, 0 }, ;
{ "AUTHOR", 'C', 40, 0 }, ; :-)
{ "DATE", 'D', 8, 0 }, ; :-)
{ "LIKE", 'N', 1, 0 }, ; :-)
{ "T_DELETE", 'N', 1, 0 }, ; :-)
{ "INFO1", 'C', 15, 0 }, ; :-)
{ "INFO2", 'C', 15, 0 }, ; :-)
{ "FORUM", 'N', 1, 0 }, ; :-)
{ "CODE", 'M', 10, 0 } }, "DBFCDX", .T., "DB" )


creating indexes for files < Samples1 - 7 >

Code (fw): Select all Collapse
I := 1
FOR I := 1 TO 7
    X := LTRIM(STR(I))
    cFileName   := "SAMPLES" + X
    IF !File( c_path + cFilename + ".CDX" )

        DBSELECTAREA(cFileName)
        //FW_CdxCreate() //  WORKS !!!
  
        ORDCREATE( ,"TOPICNO", "DESCEND( STR( TOPICNO ) )", ;
                {|| DESCEND(STR( TOPICNO ) ) } , .F. )  
        ORDCREATE( ,"FORUM","STR( FORUM )", ;
                {|| STR( FORUM ) } , .F. )  
        ORDCREATE( ,"DELETE","STR( T_DELETE )", ;
                {|| STR( T_DELETE ) } , .F. )  
        ORDCREATE( ,"DATE","DTOS( DATE )", ;
                {|| DTOS( DATE ) } , .F. )  
        ORDCREATE( ,"AUTHOR","AUTHOR + INFO1 + INFO2", ;
                {|| AUTHOR  + INFO1 + INFO2 } , .F. )
        ORDCREATE( ,"LIKE", "STR( LIKE ) + AUTHOR + INFO1 + INFO2 ) ", ;
                {|| STR( LIKE ) + AUTHOR + INFO1 + INFO2 } , .F. )      
        ORDCREATE( ,"INFO1","INFO1", ;
                {|| INFO1 } , .F. )         
        ORDCREATE( ,"INFO2","INFO2", ;
                {|| INFO2 } , .F. )         

    ENDIF
NEXT


I got it working deleting all STR( for only numeric fields
but what to do with < STR( LIKE ) + AUTHOR + INFO1 + INFO2 > numeric + text + text + text :-)

regards
Uwe :-)
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: A question about function FW_Cdxcreate()
Posted: Tue Feb 27, 2018 02:51 AM

FW_CdxCreate( [caTagList], [lMemory] ) --> lSuccess

Works only for DBFCDX. It is desirable to delete the existing cdx and open the DBF in exclusive mode before calling this function.

Param.2: [lMemory] Defaults to .F.. If .t., creates temporary index in memory with bag name "TMP"

Param.1: [caTagList]
DEFAULT: All fields excepting memo fields. All character fields are indexed with UPPER(<fldname>). Other fields are indexed with their own data types, i.e., not converted as character type. In addition, a tag with name "DELETED" is created with expression "DELETED()". This tag is meant for optimization of navigation by setting filter to "!DELETED()".

caTagList can be specified as a comma-delimited list of field names. "DELETED" can also be specified as a field name.

caTaglist can also be specified as an array of fieldnames/expressions. Each if the element can be a field name or an array of {expression, tagname}.

Regards



G. N. Rao.

Hyderabad, India
Posts: 1487
Joined: Tue Jun 14, 2016 07:51 AM
Re: A question about function FW_Cdxcreate()
Posted: Tue Feb 27, 2018 08:02 AM

Mr. Rao,

In many posts, i have seen the advice of creating ALL the indexes with a deleted() into it.

// Also do all your indexes "for ! deleted()"
// And you MUST USE the TAG clause!

use customer
index on chgno tag "custid" to customer for ! deleted()
index on descrip tag "company" to customer for ! deleted()
index on phone tag "phone" to customer for ! deleted()
...

You use a other approach with the set filter ?

In my case, in Xbrowse 1 have many indexes, and many deleted records. At a given moment I would like to show also the deleted one.
So best I set a Checkbox for toggle the Xbrowse deleted with a filter condition then ?
If so, I can search for samples here.

Marc Venken

Using: FWH 23.08 with Harbour
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: A question about function FW_Cdxcreate()
Posted: Tue Feb 27, 2018 08:33 AM
Mr. Rao,

thank You very much for the info

Code (fw): Select all Collapse
Other fields are indexed with their own data types, i.e., not converted 
as character type.


that seems to be the reason that it works without problems.
As soon a create a index with STR( field ) // numeric
I'm getting problems. But I have to define it with a index-mix of C and N.
I didn't test < cValToChar > lets see what happens.

regards
Uwe :-)
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: A question about function FW_Cdxcreate()
Posted: Tue Feb 27, 2018 08:38 AM
As soon a create a index with STR( field ) // numeric
I'm getting problems.

There is nothing wrong with it.
What kind of problems are you getting?
Regards



G. N. Rao.

Hyderabad, India
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: A question about function FW_Cdxcreate()
Posted: Tue Feb 27, 2018 09:39 AM
Mr. Rao,

the problem is a index numeric + text + text
I changed STR(nVal) to cValtoChar(nVal) and that seems to work :-)
But now my external dbf-editor shows a errormessage because he doesn't know -> cValtoChar

I want to sort the two defined filters inside LIKE and it looks OK now



seek LIKE 25, 50, 75 or 100 %



regards
Uwe :-)
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: A question about function FW_Cdxcreate()
Posted: Tue Feb 27, 2018 03:24 PM

STR(..) should not give any error, if LIKE is a numeric field.
We need to use common functions only in index expressions.

Regards



G. N. Rao.

Hyderabad, India

Continue the discussion