CDX Index File errors.

This forum is for general support of Xbase++
Message
Author
dougtanner
Posts: 32
Joined: Fri Jan 20, 2012 9:24 am

CDX Index File errors.

#1 Post by dougtanner »

I have a problem when a .CDX is created in the following example. The index key is 140 characters with the field “Collection” included. xBase++ does not like this length and errors when the index is opened. It I remove “Collection”. The key index length is 85 and the program does not error. The docs state the “Max length for both INDEX plus FOR expression is 512 characters”. What am I doing wrong?

Thanks for your time.

Doug

PROCEDURE MAIN
LOCAL mDBPath := ""
LOCAL mDBIndex := "TESTCDX"
LOCAL mCdbKeyC := 'RunCode + EndPeriod + StrPeriod + Sequence + ' +;
' EndYrWk + StrYrWk + Type + Plant + PMSType + SysTyGrIt + Collection'

LOCAL mBdbKeyC := {|| RunCode + EndPeriod + StrPeriod + FIELD->Sequence +;
EndYrWk + StrYrWk + Type + Plant + PMSType + SysTyGrIt + FIELD->Collection}

DBCREATE("TESTCDX",{;
{"RunCode","C", 5, 0},;
{"EndPeriod","C", 4, 0},;
{"StrPeriod","C", 4, 0},;
{"EndYrWk","C", 4, 0},;
{"StrYrWk","C", 4, 0},;
{"Sequence","C", 2, 0},;
{"RPTSEQ","C", 8, 0},;
{"Type","C", 1, 0},;
{"Plant","C", 4, 0},;
{"A","C", 17, 0},;
{"PMSType","C", 2, 0},;
{"SysTyGrIt","C",55, 0},;
{"Collection","C",55, 0};
})

USE TESTCDX NEW EXCLUSIVE VIA "DBFCDX"

* Create The Indexes
@24,0 SAY PADC("Creating PMS Customer Data Code Order Indexes",80)
* ALTD()
* the following errors with a "Length of database field exceeded" when
* typed at the debugger command line
ORDCREATE("TESTCDX", "CUSTOMER_O", mcdbkeyC, mbdbkeyC)

SET INDEX TO
* This errors with a "file cannot be opened"
SET INDEX TO ("TESTCDX")

RETURN

User avatar
rdonnay
Site Admin
Posts: 4729
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: CDX Index File errors.

#2 Post by rdonnay »

Doug -

I suggest adding FIELD-> to the front of each field name in the index and see if it helps.

Roger
The eXpress train is coming - and it has more cars.

User avatar
Auge_Ohr
Posts: 1407
Joined: Wed Feb 24, 2010 3:44 pm

Re: CDX Index File errors.

#3 Post by Auge_Ohr »

dougtanner wrote:I have a problem when a .CDX is created in the following example. The index key is 140 characters with the field “Collection” included. xBase++ does not like this length and errors when the index is opened. It I remove “Collection”. The key index length is 85 and the program does not error. The docs state the “Max length for both INDEX plus FOR expression is 512 characters”. What am I doing wrong?
dont know where you got these wrpng Information, see PDR 5694
For fields of type character the maximum length of the index value
is 120 characters. When the CDXDBE runs is in FOXPRO2X or COMIX mode
then the maximum length of the key value is 240. This is not documented.
greetings by OHR
Jimmy

dougtanner
Posts: 32
Joined: Fri Jan 20, 2012 9:24 am

Re: CDX Index File errors.

#4 Post by dougtanner »

Thanks for you help. Alaska support agrees that the documentation is misleading (Translation "It's Wrong") and recommends limited the length of the key for CDXs to 100 characters. Without much effort, I can rewrite the code. I would prefer not to go with COMIX or FOXPRO2. (Alaska said, and I verified that my example would not run in FOXPRO).

Doug

User avatar
rdonnay
Site Admin
Posts: 4729
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: CDX Index File errors.

#5 Post by rdonnay »

Doug -

What is your reason for not liking COMIX?
I used this format in all of my Clipper apps.

Roger
The eXpress train is coming - and it has more cars.

dougtanner
Posts: 32
Joined: Fri Jan 20, 2012 9:24 am

Re: CDX Index File errors.

#6 Post by dougtanner »

Hi Roger,

" What is your reason for not liking COMIX?"

Fear of the unknown and I couldn't get it to work. I tried adding:
DbeInfo( COMPONENT_ORDER, CDXDBE_MODE, CDXDBE_FOXPRO2X )
and it still didn't work. How can I enable COMIX?

Doug

User avatar
rdonnay
Site Admin
Posts: 4729
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: CDX Index File errors.

#7 Post by rdonnay »

DbeInfo( COMPONENT_ORDER, CDXDBE_MODE, CDXDBE_COMIX )
The eXpress train is coming - and it has more cars.

dougtanner
Posts: 32
Joined: Fri Jan 20, 2012 9:24 am

Re: CDX Index File errors.

#8 Post by dougtanner »

Hi Roger,

I added "COMIX" to my DBESYS. Changed my program to the following. It errors when the key length gets to 121.

What am I doing wrong?

Doug

PROCEDURE MAIN

LOCAL mDBPath := ""
LOCAL mDBIndex := "TESTCDX"

LOCAL cDBKeyC := "KeyField"
LOCAL bDBKeyC := {|| FIELD->KeyField}



FOR mLen := 1 TO 140

IF FILE("TESTCDX.DBF")
FERASE("TESTCDX.DBF")
ENDIF
IF FILE("TESTCDX.CDX")
FERASE("TESTCDX.CDX")
ENDIF
? mlen
DBCREATE("TESTCDX",{;
{"KeyField","C", mLen, 0}})

USE TESTCDX NEW EXCLUSIVE VIA "DBFCDX"

ORDCREATE("TESTCDX", "TESTING", cdbkeyC, bdbkeyC)

SET INDEX TO

* This errors with a "file cannot be opened" when length = 121
SET INDEX TO ("TESTCDX")

CLOSE ALL
NEXT
RETURN

User avatar
Auge_Ohr
Posts: 1407
Joined: Wed Feb 24, 2010 3:44 pm

Re: CDX Index File errors.

#9 Post by Auge_Ohr »

dougtanner wrote:I added "COMIX" to my DBESYS. Changed my program to the following. It errors when the key length gets to 121.

What am I doing wrong?
"where" is you DBESYS ? did you compile and link it after modification ?

if you do not use a *.XPJ you have to modify your "Main" this Way

Code: Select all

PROCEDURE dbeSys()

   // NTX
   IF !DbeLoad( "DBFDBE", .T. )
      ALERT( MSG_DBFDBE_NOT_LOADED, { "OK" } )
   ENDIF
   IF !DbeLoad( "NTXDBE", .T. )
      ALERT( MSG_NTXDBE_NOT_LOADED, { "OK" } )
   ENDIF
   IF !DbeBuild( "DBFNTX", "DBFDBE", "NTXDBE" )
      ALERT( MSG_DBFNTX_NOT_CREATED, { "OK" } )
   ENDIF
   
  // CDX
   IF !DbeLoad( "CDXDBE", .T. )
      ALERT( MSG_CDXDBE_NOT_LOADED", { "OK" } )
   ENDIF
   IF !DbeLoad( "FOXDBE", .T. )
      ALERT( MSG_FOXDBE_NOT_LOADED, { "OK" } )
   ENDIF
   IF !DbeBuild( "FOXCDX", "FOXDBE", "CDXDBE" )
      ALERT( MSG_FOXCDX_NOT_CREATED, { "OK" } )
   ENDIF
   //
   // Cl*pper Comix/SixDrive using FOXDBE (DATA-Komponente) 
   // 
   DbeInfo( COMPONENT_DATA, FOXDBE_CREATE_2X, .T. )
   //
   // if used together with Cl*pper
   // 
   DbeInfo( COMPONENT_DATA, FOXDBE_LOCKMODE, FOXDBE_LOCKMODE_CLIPPER )
   //
   // Cl*pper Comix using CDXDBE (ORDER Komponente) 
   //
   DbeInfo( COMPONENT_ORDER, CDXDBE_MODE, CDXDBE_COMIX )

   // default set to CDX
   DbeSetDefault( "FOXCDX" )
RETURN

PROCEDURE MAIN
i recommend to create you "Comix" DBF new*** before create Index.

*** if you use more than 1 DBE be sure to use "right" DBE ( here DBENTX and FOXCDX )

Code: Select all

     DbCreate( "TESTCDX",{{"KeyField","C", mLen, 0}}, "FOXCDX" ) 
greetings by OHR
Jimmy

dougtanner
Posts: 32
Joined: Fri Jan 20, 2012 9:24 am

Re: CDX Index File errors.

#10 Post by dougtanner »

Thanks, Auge_Ohr

Those changes to my dbesys() worked. You and Roger are the best!

Doug

Post Reply