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:
00570960
Views:
19
>>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\"
>
><b>lnFH = FOPEN(lcPath + lcTable + ".cdx", 12)</b> 
Typo here.
    lnFH = FOPEN(lcPath + lcTable + ".dbf", 12) && Correct line
>
>* 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)
>
Thanks a lot, Sergey, I'll try some more tests.
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform