Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Rebuilding structural index problem
Message
From
03/10/2007 16:43:22
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Rebuilding structural index problem
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Network:
Novell 6.x
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01258346
Message ID:
01258346
Views:
59
Hello All!

I've problem running my routine that rebuilds corrupt .cdx files. I've a table that contains the tag names as well as the associated index expression. The function is listed below. The problem occurs whenever I remove the .cdx. Error msg states "Structual CDX file not found". I'd like to circumvent this error and allow the recreation process to continue. Any help would be greatly appreciated.

here is the code:
FUNCTION mkecdx
* -------------------------------------------------------*
PARAMETERS p_tabname	&& tabname is the name of the dbf to indexed

LOCAL l_retval, cOrigArea, x, nCount, n_totkeys, cKey, cCDXFile, cExpr, cTagname

SET SAFETY OFF
l_retval = .F.
x = 1
cKey = SUBSTR(UPPER(p_tabname),1,5)

IF !USED('cdxtable')
      USE cdxtable INDEX cdxtable ALIAS cdxtable EXCLUSIVE IN 0
ENDIF

SELECT cdxtable    && table contains tag names and expressions
SET ORDER TO 1
IF SEEK(cKey)

	cCDXFile = p_tabname+'.CDX'
	IF FILE( cCDXFile )
		USE ( p_tabname) INDEX (p_tabname) ALIAS Prime IN 0 EXCLUSIVE
		SELECT Prime
		DELETE TAG ALL OF (p_tabname)
		IF FILE(cCDXFile)	&& check to see if file has been erased
			MESSAGEBOX('Error erasing '+p_tabname+'.CDX',0+16,'System Error',50)
			RETURN l_retval
		ENDIF
	ELSE
		USE ( p_tabname) ALIAS Prime IN 0 EXCLUSIVE
		SELECT Prime

	ENDIF

	DO WHILE cdxtable.dbfkey = cKey .AND. !EOF()
		cExpr = TRIM(cdxtable.EXPR)
		cTagname = cdxtable.DESC
		INDEX ON &cExpr TAG &cTagname
		SKIP IN cdxtable
	ENDDO
	SELECT Prime
	USE
	l_retval = .T.
	
ENDIF

RETURN l_retval
ENDFUNC
Next
Reply
Map
View

Click here to load this message in the networking platform