Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

"Data Dictionary" for VFP 8/9 1

Status
Not open for further replies.

mdav2

Programmer
Aug 22, 2000
363
GB
I am trying to create a program to list all the fields, data types and indexs for free field tables in a visual foxpro 8/9 database.

I have looked through some of the forums and found two posts that give ways of creating data dictionaries for database containers but I can't seem to find anything, other than the DISPLAY STRUCTURE command, that would do this for free tables. DISPLAY STRUCTURE, does not seem to include indexes either and is limited.

I have been trying to find details for a table collection but there dosen't seem to be anything like this for VFP that I can see.

Anyone any pointers on what or where to look for information on this?

Mark Davies
Warwickshire County Council
 
Hi Mark,

one way would be to ADD TABLE those free tables to a DBC and then FREE TABLES after you got your data dictionary.

I also think Stonefield Database Toolkit will work on free tables too.

And you always can use AFIELDS() and ATAGINFO(), also on free tables. Why would that be limited to a DBC?

Bye, Olaf.
 
I have a table called SysIndex that I store the CDX info in.
Sysindex has one record per table and the index info is in a memo field.
Here is how I do it for version 8&9 if it helps.

Code:
PROCEDURE VFP_V8
LOCAL lcString AS CHARACTER
LOCAL lnTags AS NUMBER
*
* Get Tag Information In an Array
*
lnTags=ATAGINFO(laCdxTag)
IF lnTags > 0
	FOR x = 1 TO lnTags
		lcString = "INDEX ON " + laCdxTag[x,3] + " TAG " +laCdxTag[x,1] + " "
		IF !EMPTY(laCdxTag[x,4])
			lcString = lcString  + "FOR " + laCdxTag[x,4] + " "
		ENDIF
		IF !EMPTY(laCdxTag[x,5])
			lcString = lcString + laCdxTag[x,5] + " "
		ENDIF
		IF laCdxTag[x,2] <> "REGULAR"
			lcString = lcString + laCdxTag[x,2] + " "
		ENDIF
		IF x = 1
			REPLACE sysindex.CDXPRG WITH lcString+CHR(13)+CHR(10)
		ELSE
			REPLACE sysindex.CDXPRG WITH lcString+CHR(13)+CHR(10) ADDITIVE
		ENDIF
	ENDFOR
ENDIF
*
USE
SELECT sysindex
RELEASE lcString,lnTags,laCdxTag,x
RETURN

David W. Grewe Dave
 
Mark,

What tools did you find that work with DBC-based tables? It's likely that these could easily be modified to work to with free tables. For example, if they use ADBOBJECT() to get a list of the tables, these could perhaps be modified to use ADIR() instead.

Olaf suggested Stonefield Database Toolkit. This does indeed work with free tables. I used this once on a project, and it worked very well, although it might be overkill for what you want.

One other possibility: Take a look at my article Generate a database automatically from a schema document. It's a different approach to what you have in mind, but it's one that has worked very well for me.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Mark.
Took me a while to find it because I converted most my code to use databases, but since Olaf mentioned AFIELDS() here is a alternative way of doing it before AFIELDS was available.
Code:
USE (lcDbfName) 
lnFcount = FCOUNT()
FOR lnX = 1 TO lnFcount
	lcField = FIELD(lnX)
	data2chk = &lcField
	DATATYPE = VARTYPE(data2chk)
.... do what you need to save the datatype
ENDFOR

David W. Grewe Dave
 
Doh, I should learn to read!

Regards

Griff
Keep [Smile]ing
 
Thanks to everyone who has responded. . I think I need to find an hour or two to look through all this and work out my best options. I did look at the stonefield database program but thought there must be a similar way to do it via code and object collections. Looks like it is possible so will write a small app to do it.

Mark Davies
Warwickshire County Council
 
The PDM tool is really good as it pretty much documents everything you would possibly need. I have run it through against one of my projects and had no issues with errors.

The Stonefield tools is a bit of overkill for what I need.

I may still create a small app to drop specific table details using the AFIELDS and ADIR into excel\word for documenting.

Mark Davies
Warwickshire County Council
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top