I've managed to handle this type of error. You must have copies of empty indexes. I have copies with 'cdxbkp' extension, included in executable. Create a table, test.dbf, with a associated CDX. Close the table and create a copy of TEST.CDX to TEST.CDXBKP. Then edit the CDX file and delete everything in it (corruption simulation).
Try the code (extracted from my error handler program)
lReindexFalg = .f.
lcDbfToOpen = 'test'
ON ERROR do CDx_error with lcDbfToOpen
USE (lcDbfToOpen)
IF lReindexFlag = .t.
REINDEX
ENDIF
PROCEDURE CDX_error
LPARAMETERS tcDbfToOpen
IF INLIST(ERROR() , 114, 19 )
erase (tcDbfToOpen+'.cdx')
copy file (tcDbfToOpen+'.'+'cdxbkp' ) to ;
( tcDbfToOpen+'.'+'cdx' )
lReidexFlag = .t.
RETRY
ENDIF
This work for me.
>One more thing about this error, that is really really annoying.
>
>The ERROR message itself recommends: "Delete INDEX and recreate". As though this is possible and one can actually do that!!!.
>
>When I tell my customers, with this error, we are at the end of the road and they need to restore from TAPE backup, the customer always asks, WHY don't you do as the message says; DELETE the Index and recreate it?....
>So, I look like a fool, and they lose a day's work.
>
>This has happened more than a few time... I am now actually trapping that error message and removing the "Recommendation" portion of it!