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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

"Displaying Structure to Printer" 2

Status
Not open for further replies.

SMCmtg

Programmer
Mar 27, 2000
90
US
DISPLAY STRUCTURE TO PRINTER prints out in field # sequence. What I would like to do is print out in field name sequence.&nbsp;&nbsp;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 &quot;display the structure of the dbf or cursor&quot;? or maybe a&nbsp;&nbsp;&quot;View&quot; ? 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&nbsp;&nbsp;&nbsp;c&nbsp;&nbsp;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&nbsp;&nbsp;&nbsp;: SYS_DICT.PRG<br>*/System&nbsp;&nbsp;&nbsp;&nbsp;:<br>*/Purpose&nbsp;&nbsp;&nbsp;: Create a generic data dictionary program<br>*/Syntax&nbsp;&nbsp;&nbsp;&nbsp;: =SYS_DICT() or =SYS_DICT(&quot;c:\xxx\xxx&quot;)<br>*/Returns&nbsp;&nbsp;&nbsp;: nothing<br>*/Parameter : DIR - string - Directory to build the data dictionary in<br>*/Defaults&nbsp;&nbsp;: dir = sys(5)+sys(2003)<br>*/Requires&nbsp;&nbsp;: nothing<br>*/Changes&nbsp;&nbsp;&nbsp;: SYS_DICT.DBF<br>*/Version&nbsp;&nbsp;&nbsp;: 1.0<br>*/Dated&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;: 23 May 1993<br>*/Written By: David W. Grewe<br>*/***************************************************************************<br>*& Utility - Programing<br>*/***************************************************************************<br>*/ Record Of Change<br>*/<br>*/***************************************************************************<br>*/ Program standards:<br>*/&nbsp;&nbsp;&nbsp;FoxPro Command Words - lower case<br>*/&nbsp;&nbsp;&nbsp;Memory Variables & UDFs - UPPER CASE<br>*/&nbsp;&nbsp;&nbsp;Memory variable naming method:<br>*/&nbsp;&nbsp;&nbsp;F_ (Global - File) Holds Info About The User.<br>*/&nbsp;&nbsp;&nbsp;C_ (Global - Constant) once defined they are never changed.<br>*/&nbsp;&nbsp;&nbsp;G_ (Global - Public&nbsp;&nbsp;) may be accessed/changed by any file or procedure.<br>*/&nbsp;&nbsp;&nbsp;P_ (Private - used to pass values as parameters to and from procedures.<br>*/&nbsp;&nbsp;&nbsp;L_ (Private - used only inside a file or procedure.<br>*/***************************************************************************<br>parameter pcSearchPath<br>if parameters() &lt; 1 or type(&quot;pcSearchPath&quot;) # &quot;C&quot;<br>&nbsp;&nbsp;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>&nbsp;&nbsp;wait window proper(pcSearchPath) + chr(13) + &quot;is not a valid path !!&quot;<br>&nbsp;&nbsp;on error<br>&nbsp;&nbsp;set defa to &lcStartDir<br>&nbsp;&nbsp;return<br>endif<br>*<br>if right(pcSearchPath,1) != &quot;\&quot;<br>&nbsp;&nbsp;pcSearchPath = pcSearchPath + &quot;\&quot;<br>endif<br>*<br>if upper(pcSearchPath) = sys(2004)<br>&nbsp;&nbsp;set defa to &lcStartDir<br>&nbsp;&nbsp;wait window &quot;FoxPro launch directory &quot; + chr(13) + ;<br>&nbsp;&nbsp;&nbsp;&nbsp;proper(sys(2004)) + &quot; is not available !!&quot;<br>&nbsp;&nbsp;on error<br>&nbsp;&nbsp;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 + &quot;SYS_DICT.DBF&quot;<br>lcDataCdx=pcSearchPath + &quot;SYS_DICT.CDX&quot;<br>lcDataFpt=pcSearchPath + &quot;SYS_DICT.FPT&quot;<br>*<br>* Open/Create Databases<br>*<br>if file(lcDataDbf)<br>&nbsp;&nbsp;use (lcDataDbf) order table alias SYS_DICT exclu<br>&nbsp;&nbsp;copy stru to C:\TEMP<br>&nbsp;&nbsp;select 0<br>&nbsp;&nbsp;use C:\TEMP exclu<br>else<br>&nbsp;&nbsp;return<br>endif<br>set order to table<br>*<br>* Test for dbf files in specified path<br>*<br>lnDbfs=adir(laDbfs,&quot;*.DBF&quot;)<br>if lnDbfs &lt; 1<br>&nbsp;&nbsp;wait window proper(pcSearchPath) + chr(13) + &quot;does not contain databases !!&quot;<br>else<br>*<br>* ran out of reasons not to do it so here goes<br>*<br>&nbsp;&nbsp;=asort(laDbfs)<br>&nbsp;&nbsp;@ 1,1 say &quot;Databases To Place In Dictionary&quot;<br>&nbsp;&nbsp;@ 2,12 say lnDbfs<br>&nbsp;&nbsp;@ 3,1 say &quot;Completed&quot;<br>&nbsp;&nbsp;for I = 1 to lnDbfs<br>&nbsp;&nbsp;&nbsp;&nbsp;@ 3,12 say I<br>&nbsp;&nbsp;&nbsp;&nbsp;@ 4,12 say padr(laDbfs(I,1),15)<br>&nbsp;&nbsp;&nbsp;&nbsp;do case<br>&nbsp;&nbsp;&nbsp;&nbsp;case upper(laDbfs(I,1))=&quot;SYS_DICT.DBF&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;loop<br>&nbsp;&nbsp;&nbsp;&nbsp;case upper(laDbfs(I,1))=&quot;FOXUSER.DBF&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;loop<br>&nbsp;&nbsp;&nbsp;&nbsp;case substr(upper(laDbfs(I,1)),1,4)=&quot;TEMP&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;loop<br>&nbsp;&nbsp;&nbsp;&nbsp;case substr(upper(laDbfs(I,1)),1,3)=&quot;DWG&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;loop<br>&nbsp;&nbsp;&nbsp;&nbsp;endcase<br>*<br>*&nbsp;&nbsp;&nbsp;put field structure into to an array<br>*<br>&nbsp;&nbsp;&nbsp;&nbsp;lnError=0<br>&nbsp;&nbsp;&nbsp;&nbsp;on error lnError=ERRORTRAP()<br>&nbsp;&nbsp;&nbsp;&nbsp;select 0<br>&nbsp;&nbsp;&nbsp;&nbsp;use laDbfs(I,1) alias IMPORT shared<br>&nbsp;&nbsp;&nbsp;&nbsp;if lnError &lt; 0<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;on error<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;loop<br>&nbsp;&nbsp;&nbsp;&nbsp;endif<br>&nbsp;&nbsp;&nbsp;&nbsp;on error<br>&nbsp;&nbsp;&nbsp;&nbsp;copy stru extended to c:\stru<br>&nbsp;&nbsp;&nbsp;&nbsp;use<br>&nbsp;&nbsp;&nbsp;&nbsp;select temp<br>&nbsp;&nbsp;&nbsp;&nbsp;zap<br>&nbsp;&nbsp;&nbsp;&nbsp;append from c:\stru<br>&nbsp;&nbsp;&nbsp;&nbsp;replace all table with strtran(laDbfs(I,1),&quot;.DBF&quot;,&quot;&quot;)<br>&nbsp;&nbsp;&nbsp;&nbsp;goto top<br>*<br>*&nbsp;&nbsp;&nbsp;populate the data database<br>*<br>&nbsp;&nbsp;&nbsp;&nbsp;scan all<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;scatter memvar memo<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if !seek(M.TABLE+M.FIELD,&quot;SYS_DICT&quot;)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;insert into SYS_DICT from memvar<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;endif<br>&nbsp;&nbsp;&nbsp;&nbsp;endscan<br>*<br>&nbsp;&nbsp;&nbsp;&nbsp;select TEMP<br>&nbsp;&nbsp;&nbsp;&nbsp;zap<br>&nbsp;&nbsp;endfor<br>*<br>endif<br>close databases<br>delete file (&quot;C:\TEMP.DBF&quot;)<br>delete file (&quot;C:\TEMP.CDX&quot;)<br>delete file (&quot;C:\TEMP.FPT&quot;)<br>delete file (&quot;C:\STRU.DBF&quot;)<br>delete file (&quot;C:\STRU.CDX&quot;)<br>delete file (&quot;C:\STRU.FPT&quot;)<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>*!&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Procedure: ERRORTRAP<br>*!<br>*!&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;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=mailto:Dave@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.&nbsp;&nbsp;(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.&nbsp;&nbsp;I didn't spend the time to write the code but it could be done.&nbsp;&nbsp;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&quot;Asort()&quot; <br>That was the brain cell that got lost. . .<br>I set up a table called FIELDORDER with 17 fields.&nbsp;&nbsp;<br>(&quot;fieldname&quot; C25 and 15 others for field characteristics, and field 17 called &quot;tablename&quot; 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&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&&first table to sort by fieldname<br>&nbsp;&nbsp;&nbsp;Afields(tableorder)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&&array setup<br>&nbsp;&nbsp;&nbsp;Asort(tableorder,1)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&&sort array<br>Select fieldorder&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&&table to append array<br>Append from Array tableorder<br>Go Top<br>Do While .t.&nbsp;&nbsp;&nbsp;&&loop to fill field 17 with table name<br>&nbsp;&nbsp;If eof()<br>&nbsp;&nbsp;&nbsp;&nbsp;exit<br>&nbsp;&nbsp;else<br>&nbsp;&nbsp;If empty(tablename)=.t.<br>&nbsp;&nbsp;&nbsp;&nbsp;Replace tablename with 'table1'<br>&nbsp;&nbsp;Endif<br>Endif<br>Skip<br>Loop<br>Enddo<br>Select table2&nbsp;&nbsp;&&&&&&&To add&nbsp;&nbsp;all or other tables of project<br>. <br>.<br>Select fieldorder&nbsp;&nbsp;<br>Set order to fieldname&nbsp;&nbsp;&&&set order to field name plus table name alpha...use in form, browse, print, whatever<br><br>THX, appreciate all your help!<br><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top