DISPLAY STRUCTURE TO PRINTER prints out in field # sequence. What I would like to do is print out in field name sequence. Is there any way to accomplish this?<br>Appreciate any direction.<br>THX
I haven't gone to the books, but off the top of my head,<br>you could modify the structure of the table so that the names are in the order you want -- Short of that you might do an ordered query and display the structure of the resulting dbf or cursor.<br><br>--cd.
CDavis:<br>Thanks for your comments. . .my problem is that I have<br>over 30 tables of 254 fields each(the limit)7000+ fields. . .mostly 1n1, As I was building the data environment I never thought I might want alpha, My reason now is to audit fields names. . .makes me wonder if I didn't build it fundamentally wrong! How would I "display the structure of the dbf or cursor"? or maybe a "View" ? Feedback requested<br>THX<br><br>
You might want to check out the afields() and asort() functions. You could write some code with these to accomplish what you want.<br><br>You might also play around with the copy structure extended command.<br><br>create a table with to hold the info with something like...<br><br>fieldname c 25<br>whatever else<br><br>call it tableorder or some clever name... then...<br><br><br>use yourfirsttable<br>copy stru extended to temp<br>use tableorder in 2<br>append from temp<br><br>Loop through however you need too then....<br><br>use tableorder<br>index on fieldname tag whatever<br><br>report form xxx to prin<br><br>Well I think you probably get the idea.<br><br><br>Hope this helps<br>Tom Gahagan<br>REST<br>
Would This Help, The structure of Sys_Dict.Dbf is easy, It is the same as Copy Stru Extended.<br><br><br>*/***************************************************************************<br>*/Program : SYS_DICT.PRG<br>*/System :<br>*/Purpose : Create a generic data dictionary program<br>*/Syntax : =SYS_DICT() or =SYS_DICT("c:\xxx\xxx"<br>*/Returns : nothing<br>*/Parameter : DIR - string - Directory to build the data dictionary in<br>*/Defaults : dir = sys(5)+sys(2003)<br>*/Requires : nothing<br>*/Changes : SYS_DICT.DBF<br>*/Version : 1.0<br>*/Dated : 23 May 1993<br>*/Written By: David W. Grewe<br>*/***************************************************************************<br>*& Utility - Programing<br>*/***************************************************************************<br>*/ Record Of Change<br>*/<br>*/***************************************************************************<br>*/ Program standards:<br>*/ FoxPro Command Words - lower case<br>*/ Memory Variables & UDFs - UPPER CASE<br>*/ Memory variable naming method:<br>*/ F_ (Global - File) Holds Info About The User.<br>*/ C_ (Global - Constant) once defined they are never changed.<br>*/ G_ (Global - Public   may be accessed/changed by any file or procedure.<br>*/ P_ (Private - used to pass values as parameters to and from procedures.<br>*/ L_ (Private - used only inside a file or procedure.<br>*/***************************************************************************<br>parameter pcSearchPath<br>if parameters() < 1 or type("pcSearchPath" # "C"<br> pcSearchPath = sys(5)+sys(2003)<br>endif<br>*<br>set default to (pcSearchPath) && Shift default to work area<br><br>set step on<br><br>if sys(5)+sys(2003) != pcSearchPath<br> wait window proper(pcSearchPath) + chr(13) + "is not a valid path !!"<br> on error<br> set defa to &lcStartDir<br> return<br>endif<br>*<br>if right(pcSearchPath,1) != "\"<br> pcSearchPath = pcSearchPath + "\"<br>endif<br>*<br>if upper(pcSearchPath) = sys(2004)<br> set defa to &lcStartDir<br> wait window "FoxPro launch directory " + chr(13) + ;<br> proper(sys(2004)) + " is not available !!"<br> on error<br> return<br>endif<br>*<br>* set enviroment<br>*<br>close all<br>clear<br>set sysmenu on<br>set sysmenu to default<br>set exclu off<br>set exact on<br>set talk off<br>set exclusive off<br>set safety off<br>on error **<br>*<br>* declare memvars<br>*<br>lnDbfs=0<br>lnFields=0<br>lcStartDir = sys(5)+sys(2003)<br>lcDataDbf=pcSearchPath + "SYS_DICT.DBF"<br>lcDataCdx=pcSearchPath + "SYS_DICT.CDX"<br>lcDataFpt=pcSearchPath + "SYS_DICT.FPT"<br>*<br>* Open/Create Databases<br>*<br>if file(lcDataDbf)<br> use (lcDataDbf) order table alias SYS_DICT exclu<br> copy stru to C:\TEMP<br> select 0<br> use C:\TEMP exclu<br>else<br> return<br>endif<br>set order to table<br>*<br>* Test for dbf files in specified path<br>*<br>lnDbfs=adir(laDbfs,"*.DBF"<br>if lnDbfs < 1<br> wait window proper(pcSearchPath) + chr(13) + "does not contain databases !!"<br>else<br>*<br>* ran out of reasons not to do it so here goes<br>*<br> =asort(laDbfs)<br> @ 1,1 say "Databases To Place In Dictionary"<br> @ 2,12 say lnDbfs<br> @ 3,1 say "Completed"<br> for I = 1 to lnDbfs<br> @ 3,12 say I<br> @ 4,12 say padr(laDbfs(I,1),15)<br> do case<br> case upper(laDbfs(I,1))="SYS_DICT.DBF"<br> loop<br> case upper(laDbfs(I,1))="FOXUSER.DBF"<br> loop<br> case substr(upper(laDbfs(I,1)),1,4)="TEMP"<br> loop<br> case substr(upper(laDbfs(I,1)),1,3)="DWG"<br> loop<br> endcase<br>*<br>* put field structure into to an array<br>*<br> lnError=0<br> on error lnError=ERRORTRAP()<br> select 0<br> use laDbfs(I,1) alias IMPORT shared<br> if lnError < 0<br> on error<br> loop<br> endif<br> on error<br> copy stru extended to c:\stru<br> use<br> select temp<br> zap<br> append from c:\stru<br> replace all table with strtran(laDbfs(I,1),".DBF",""<br> goto top<br>*<br>* populate the data database<br>*<br> scan all<br> scatter memvar memo<br> if !seek(M.TABLE+M.FIELD,"SYS_DICT"<br> insert into SYS_DICT from memvar<br> endif<br> endscan<br>*<br> select TEMP<br> zap<br> endfor<br>*<br>endif<br>close databases<br>delete file ("C:\TEMP.DBF"<br>delete file ("C:\TEMP.CDX"<br>delete file ("C:\TEMP.FPT"<br>delete file ("C:\STRU.DBF"<br>delete file ("C:\STRU.CDX"<br>delete file ("C:\STRU.FPT"<br>set defa to &lcStartDir && Restore user default<br>release array laFields,laDbfs<br>release all<br>set sysmenu to default<br>on error<br>clear<br>return<br><br>*!*****************************************************************************<br>*!<br>*! Procedure: ERRORTRAP<br>*!<br>*! Called by: DICTDATA.PRG<br>*!<br>*!*****************************************************************************<br>procedure ERRORTRAP<br>*******************<br>return -1<br>*: EOF: DICTDATA.PRG<br><br> <p>David W. Grewe<br><a href=mailtoave@internationalbid.net>Dave@internationalbid.net</a><br><a href= > </a><br>
If what you want is to print a list of field names sorted by fieldname you could try the following -- <br><br>SELECT myTable<br>SCATTER MEMVAR MEMO BLANK<br>DISPLAY MEMORY TO myTable<br><br>You could then open myTable.txt in Word<br>Your field names will be listed at the top of the file along with all the system variable names following.<br>Delete the system variables section<br>Change the page layout to landscape<br>Sort the list<br><br>This won't give you all the information you would get in display structure. (you can also display structure to myFile but I couldn't figure out a way to easily sort the results.<br><br>Another way would be to write a .prg which sends the structure to a file (Display Structure to myFile) then in your .prg use low-level file functions to grab the information you want from myFile and insert it into a table which you could then sort and print etc. I didn't spend the time to write the code but it could be done. You could select each of your tables in turn -- you'd end up with one table that you could sort and set indexes on etc.<br><br>It might be useful code that you could post for use by others.<br><br>--cd.
Thanks to CDavis/DGrewe/Tom Gahagan for hints"Asort()" <br>That was the brain cell that got lost. . .<br>I set up a table called FIELDORDER with 17 fields. <br>("fieldname" C25 and 15 others for field characteristics, and field 17 called "tablename" C25. I indexed the table to <br>STR(fieldname+tablename)ascending. I set up the data environment of the form to all the tables in the project and set up a grid etc...<br>The sample code follows:<br><br>Select table1 &&first table to sort by fieldname<br> Afields(tableorder) &&array setup<br> Asort(tableorder,1) &&sort array<br>Select fieldorder &&table to append array<br>Append from Array tableorder<br>Go Top<br>Do While .t. &&loop to fill field 17 with table name<br> If eof()<br> exit<br> else<br> If empty(tablename)=.t.<br> Replace tablename with 'table1'<br> Endif<br>Endif<br>Skip<br>Loop<br>Enddo<br>Select table2 &&&&&&&To add all or other tables of project<br>. <br>.<br>Select fieldorder <br>Set order to fieldname &&&set order to field name plus table name alpha...use in form, browse, print, whatever<br><br>THX, appreciate all your help!<br><br>
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.