Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Automatically detect if indexes are present and delete t
Message
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00570924
Message ID:
00570950
Views:
20
>Hi everybody,
>
>I have a Fox2x table with indexes. I don't want to open it in VFP. I want to detect, does this table have indexes or not, and if yes, automatically delete them (table should be readable after this operation! :)). How can I do it by low-level functions?
>
>Thanks in advance.

Here's a code I just put together. I tested it on one free table an it works but you have to do more testing.
lcTable = "maytable"
lcPath = "C:\mypath\"

lnFH = FOPEN(lcPath + lcTable + ".cdx", 12)

* Check if there is structural CDX
= FSEEK(lnFH,28)
lnByte28 = ASC(FREAD(lnFH,1))
lnCDXStr = BITAND(lnByte28, 1)

IF lnCDXStr = 1    && there is CDX
	IF FILE(lcPath + lcTable + ".cdx")
		ERASE (lcPath + lcTable + ".cdx")
	ENDIF
        = FSEEK(lnFH,28)
        = FWRITE(lnFH, Chr( BITAND(lnByte28, 0xFE) ))
ENDIF

= FCLOSE(lnFH)
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform