>>I have an index routine that uses a KEYS.DBF file. This file contains the filename, index name, key expression and Ascending/Descending indicator.
>>
>>Is there a way to populate this file by reading the .dbc directly?
>>
>>Ideally, I'd like to run "LoadKeys()" at app startup as well as intermittently during development.
>>
>>TIA
>Larry,
>BTW VFP compared to FP2.x also has primary(), candidate() etc. + more enhanced functions like "alter table ... foreign key ...".
>Also a shortcut to all this is to generate programatic form of DBC with gendbc or gendbcx (
www.stevearnott.com) and use it.
>Cetin
Thank you all, I didn't expect so many ideas :)
Here's what I finally used
CLOS ALL
CLEA ALL
CLEA
SET TALK OFF
SET SAFE OFF
SET ESCA ON
USE KEYS EXCL
ZAP
SELECT 0
CREATE TABLE IndexLst (FileName c(10), IndexName c(10) )
SELECT * FROM main.DBC WHERE objecttype="Table" INTO CURSOR Mytables
SCAN
IF OBJECTNAME<>"keys"
SELECT * FROM main.DBC WHERE objecttype="Index" AND ParentId = Mytables.ObjectID INTO CURSOR MyIndexes
SCAN
INSERT INTO IndexLst ( FileName, IndexName ) VALUES ( Mytables.OBJECTNAME, MyIndexes.OBJECTNAME )
ENDSCAN
ENDIF
ENDSCAN
CLOS ALL
CLEA ALL
CLEA
USE IndexLst
SCAN
SELECT 0
USE ( IndexLst.FileName )
SET ORDER TO ( IndexLst.IndexName )
cIndexExpr = KEY()
? IndexLst.FileName, IndexLst.IndexName, cIndexExpr
INSERT INTO KEYS ( FLNAME, TAGNAME, INDEXEXPR ) VALUES ( UPPER( IndexLst.FileName ), UPPER( IndexLst.IndexName ), cIndexExpr )
USE
ENDSCAN
I can now use KEYS.DBF to recreate the indexes easily.
I'm a
real supporter of the KISS concept :) My indexing schemes are always confined to INDEX ON ??? TAG ??? commands... no
descending, unique, candidate, primary, etc... qualifiers.
Thanks again for all the feedback!