Page 1 of 1

A question about function FW_Cdxcreate()

PostPosted: Mon Feb 26, 2018 7:16 pm
by ukoenig
Hello,

I wanted to create individual indexes for 7 files
before I used < FW_Cdxcreate() > :D
everything works fine without problems
next I started to define extra indexes :roll:
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

Image

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

Image

Code: Select all  Expand view

        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: Select all  Expand view

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 :?:

Re: A question about function FW_Cdxcreate()

PostPosted: Mon Feb 26, 2018 8:00 pm
by karinha
Maybe:

Code: Select all  Expand view

   FW_CdxCreate()

   CLOSE DATABASE

   USE SAMPLES EXCLUSIVE VIA "DBFCDX"  // or SHARED

 


Regards

Re: A question about function FW_Cdxcreate()

PostPosted: Mon Feb 26, 2018 8:11 pm
by ukoenig
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 }, ; :cry:
{ "LINK", 'C', 70, 0 }, ;
{ "TOPIC", 'C', 65, 0 }, ;
{ "AUTHOR", 'C', 40, 0 }, ; :D
{ "DATE", 'D', 8, 0 }, ; :D
{ "LIKE", 'N', 1, 0 }, ; :cry:
{ "T_DELETE", 'N', 1, 0 }, ; :cry:
{ "INFO1", 'C', 15, 0 }, ; :D
{ "INFO2", 'C', 15, 0 }, ; :D
{ "FORUM", 'N', 1, 0 }, ; :cry:
{ "CODE", 'M', 10, 0 } }, "DBFCDX", .T., "DB" )


creating indexes for files < Samples1 - 7 >

Code: Select all  Expand view


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 :(

Re: A question about function FW_Cdxcreate()

PostPosted: Tue Feb 27, 2018 2:51 am
by nageswaragunupudi
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}.

Re: A question about function FW_Cdxcreate()

PostPosted: Tue Feb 27, 2018 8:02 am
by Marc Venken
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.

Re: A question about function FW_Cdxcreate()

PostPosted: Tue Feb 27, 2018 8:33 am
by ukoenig
Mr. Rao,

thank You very much for the info

Code: Select all  Expand view
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 :D

Re: A question about function FW_Cdxcreate()

PostPosted: Tue Feb 27, 2018 8:38 am
by nageswaragunupudi
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?

Re: A question about function FW_Cdxcreate()

PostPosted: Tue Feb 27, 2018 9:39 am
by ukoenig
Mr. Rao,

the problem is a index numeric + text + text
I changed STR(nVal) to cValtoChar(nVal) and that seems to work :shock:
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

Image

seek LIKE 25, 50, 75 or 100 %

Image

regards
Uwe :D

Re: A question about function FW_Cdxcreate()

PostPosted: Tue Feb 27, 2018 3:24 pm
by nageswaragunupudi
STR(..) should not give any error, if LIKE is a numeric field.
We need to use common functions only in index expressions.