Page 1 of 3
FOXCDX and integer
Posted: Thu May 28, 2015 3:08 am
by skiman
Hi,
I need to read a FOXCDX database which has a CDX where the tag I need to search on is an INTEGER field. I don't succeed to do a dbseek on that field. It always returns an EOF().
I already tried with alias->(dbseek( int(nValue)) and also with alias->(dbseek( nValue, .F., cTagname)). After opening the file, there is a ordsetfocus to the correct tag. When I browse the file, the order is on that field.
I tried to search in that database with xdbu, and I also don't succeed.
Anyone who knows if it is possible to seek on an index where the key is an INTEGER field.
Re: FOXCDX and integer
Posted: Thu May 28, 2015 5:05 am
by skiman
Hi,
In attachment a sample dbf with the CDX file. If I try the following in xdot, it isn't working.
Code: Select all
cls
use artikel via foxcdx
set index to artikel
ordsetfocus("artcode")
? indexkey()
q := 42300
dbseek(q)
? eof()
? a_artcode
? a_nummer
After the SEEK, the EOF is always .T..
Any help welcome.
Re: FOXCDX and integer
Posted: Thu May 28, 2015 5:13 am
by skiman
I just realized that this is the 2.0 forum. This is an xbase 1.9 issue, probably also 2.0.
Re: FOXCDX and integer
Posted: Thu May 28, 2015 5:40 am
by rdonnay
I have no problem seeking a numeric key.
I created a field named MYNUMBER, N, 5
I then created 2 index tags:
INDEX ON MYNUMBER TAG MYNUMBER
INDEX ON Int(MYNUMBER) TAG INUMBER
I filled the field like so:
REPLACE aLL MYNUMBER WITH Recno() + 11
Then I did a dbSeek(511).
It put me on record 500.
I tried this with both index tags.
I have never had a problem with numeric indexes.
Re: FOXCDX and integer
Posted: Thu May 28, 2015 5:56 am
by skiman
Hi Roger,
Yes, I also have no problems with a numeric key.
However in a Foxpro database there is a fieldtype Integer. This seems to be the cause of this problem.
I you unzip the DBF with CDX you can see the problem.
I need to synchronize a dbf with data from another application. I can open the files and seek in them. This file has an indextag on an integer field which I need. This gives me the problem.
Re: FOXCDX and integer
Posted: Thu May 28, 2015 7:58 am
by Zdeno Bielik
Hi,
try set CDXDBE_MODE for COMPONENT_ORDER to CDXDBE_FOXPRO2X or to CDXDBE_VFOXPRO.
HTH
Zdeno
Code: Select all
****************
PROCEDURE dbeSys()
****************
Set Collation To SYSTEM
/*
IF ! DbeLoad( "DBFDBE", .T.)
MsgBox( "Database engine DBFDBE not loaded" , {"OK"} )
ENDIF
IF ! DbeLoad( "CDXDBE",.T.)
MsgBox( "Database-Engine CDXDBE not loaded" , {"OK"} )
ENDIF
IF ! DbeBuild( "DBFCDX", "DBFDBE", "CDXDBE" )
MsgBox( "DBFCDX Database-Engine;is not created" , {"OK"} )
ENDIF
DbeSetDefault( "DBFCDX" )
*/
*
IF ! DbeLoad( "FOXDBE", .T.)
MsgBox( "Database engine FOXDBE not loaded" , {"OK"} )
ENDIF
IF ! DbeLoad( "CDXDBE",.T.)
MsgBox( "Database-Engine CDXDBE not loaded" , {"OK"} )
ENDIF
IF ! DbeBuild( "FOXCDX", "FOXDBE", "CDXDBE" )
MsgBox( "FOXCDX Database-Engine;is not created" , {"OK"} )
ENDIF
DbeSetDefault( "FOXCDX" )
DbeInfo( COMPONENT_DATA, DBFDBE_LOCKRETRY, 1000000 )
DbeInfo( COMPONENT_DATA, DBFDBE_LOCKDELAY, 10 )
DbeInfo( COMPONENT_DATA, DBFDBE_LIFETIME, 0 )
DbeInfo( COMPONENT_ORDER, CDXDBE_MODE , CDXDBE_FOXPRO2X )
* DbeInfo( COMPONENT_ORDER, CDXDBE_MODE , CDXDBE_VFOXPRO )
DbeInfo( COMPONENT_ORDER, CDXDBE_LOCKRETRY, 1000000 )
DbeInfo( COMPONENT_ORDER, CDXDBE_LOCKDELAY, 10 )
DbeInfo( COMPONENT_ORDER, DBE_LOCKMODE , LOCKING_EXTENDED )
*
* If ( ! DbeLoad( 'DBFDBE', .T.) )
* MsgBox( 'Databazovy stroj DBFDBE sa nenahral, koncime...', '*** Pozor ***' )
* EndIf
*
* If ( ! DbeLoad( 'NTXDBE',.T.) )
* MsgBox( 'Databazovy stroj NTXDBE sa nenahral, koncime...', '*** Pozor ***' )
* EndIf
*
* If ( ! DbeBuild( 'DBFNTX', 'DBFDBE', 'NTXDBE' ) )
* MsgBox( 'Databazovy stroj DBF-NTX sa nevytvoril, koncime...', '*** Pozor ***' )
* EndIf
*
* DbeSetDefault( "DBFNTX" )
* // default extension DBF->XDB for database files
* DbeInfo( COMPONENT_DATA , DBE_EXTENSION, "XDB" )
* // default extension CDX->XCD for index files
* DbeInfo( COMPONENT_ORDER, DBE_EXTENSION, "XCD" )
RETURN
*
Constants for DbeInfo(COMPONENT_ORDER,CDXDBE_MODE,)
Constant Description
*) ro=READONLY , a=ASSIGNABLE
CDXDBE_VFOXPRO - Visual FoxPro 5.x and higher
CDXDBE_COMIX - Comix for Clipper RDD
CDXDBE_SIX - Six for Clipper RDD
CDXDBE_FOXPRO2X - FoxPro 2.x compatiblity
Re: FOXCDX and integer
Posted: Thu May 28, 2015 8:36 am
by skiman
Hi,
try set CDXDBE_MODE for COMPONENT_ORDER to CDXDBE_FOXPRO2X or to CDXDBE_VFOXPRO.
I tried both, but it doesn't make any difference.
Re: FOXCDX and integer
Posted: Thu May 28, 2015 11:44 am
by rdonnay
You could try indexing on Str(<numfield> ) and then seek the Str() of a number.
Re: FOXCDX and integer
Posted: Thu May 28, 2015 11:54 pm
by skiman
Hi Roger,
I solved it with an extra index, but I was hoping there would be another solution.
I can't change the other application, and I can't add an extra tag to the CDX file. So my index isn't updated at the moment the DBF changes.
Adding an extra tag isn't possible because this connection will be installed on a lot of customer sites. We can't modify the CDX files. If we change them and there is a problem with the other application, they will say that we are the cause of it.
Re: FOXCDX and integer
Posted: Fri May 29, 2015 2:24 am
by PedroAlex
This works fine for me
Code: Select all
//=========================================
Function FOX()
Use ARTIKEL.DBF alias ARTIGOS Shared new
index on A_ARTCODE to ARTORDER
set index to ARTORDER
IF ARTIGOS->( DbSeek( 40010,,1))
MsgBox(A_BOMSCHRN)
Else
MsgBox('Not Found')
Endif
IF ARTIGOS->( DbSeek( 40020,,1))
MsgBox(A_BOMSCHRN)
Else
MsgBox('Not Found')
Endif
Close ARTIGOS
Return Nil
Pedro