Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
A Detailed Data Dictionary
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00043518
Message ID:
00043575
Views:
34
>>Being the detail oriented guy that I am (uh huh), I decided to automatically generate a data dictionary in my framework. The datadict is really two table, one containing table information and one containing field information. The problem I've run into is when trying to generate the table that contains field info. Basically, I attempted to do the following:
>> scan
>> get table name from datadict
>> display structure to a file
>> append that file to a temporary table
>> get rid of the strucure header info
>> add any extra info to the temp table, eg table name
>> append the temp table into the main table
>> endscan
>>
>>This works great with one exception. The file output from the 'display struct to file' isn't always the same! So, for example, since I'm assuming that the 'field type' will always start at column 30 this trashes everything.
>>
>>Is there an easier way to get structure info into a table?
>
>
>Ive done the same thing, also using two tables, I generate the field table using AFIELDS() like this:
>
>
>use db_list.751 && the table with the file listings
>recnum = reccount()
>dimension dblist(recnum)
>anum = 1
>scan for !empty(filename)
> dblist(anum) = filename
> anum = anum + 1
>endscan
>use
>sele datadict
>goto top
>for q = 1 to recnum
> select 0
> fname = dblist(q)
> use &fname
> dec = afields(zfield)
> use
> select datadict
> for x = 1 to dec
> append blank
> replace file with fname
> replace field_name with zfield(x,1)
> replace field_type with zfield(x,2)
> replace field_len with zfield(x,3)
> replace field_dec with zfield(x,4)
> next
> release all like z*
>next
>sort to datadict.751 on file,field_name
>
>
>I'm sure there are plenty of ways to control the looping, perhaps better than this, but it does create the necessary data dictionary tables.
>
>Hope this helps.
>
>Steve


Thanks for the assist. The afields() did it for me. I can't believe I didn't run across this function when I was looking for different ways to output structure info. Sheesh. Anyway, here is my final code:
*****************
select datadict
SCAN
lcName = alltrim(datadict.dbfname) && the name of the table
lcPath = alltrim(directory) && the path of the table
use (lcPath+lcName) IN 4
lnFields = afields(laFieldInfo) && copy structure info to array
select datatmp
zap
append from array laFieldInfo && append structure info into temp table
replace all dbfname with lcName && add the table the fields came from
select datafld
append from datatmp && append final data into field table
select datadict
ENDSCAN
*****************

Michael G. Emmons
memmons@nc.rr.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform