home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / magazine / nan_news / vol2 / no3 / disp.prg next >
Text File  |  1988-03-14  |  3KB  |  110 lines

  1. * Program Name: ds.prg *
  2. * Author: Don L. Powells *
  3. * (c) 1988 by Nantucket Corporation *
  4.  
  5. * Routine to display the structure of the dbf files in the 
  6. *   current directory
  7.  
  8. SAVE SCREEN TO dispscrn
  9. SCROLL(2,1,23,78,0)
  10. SET COLOR TO i
  11. CENTER(1,"ENHANCED LOCAL AREA NETWORK SUPPORT")
  12. SET COLOR TO
  13.  
  14. * Draw screen heading
  15. clear
  16. @ 3,36 say "███   █████"
  17. @ 4,36 say "█  █  █   ▀"
  18. @ 5,36 say "█   █ █████"
  19. @ 6,36 say "█  █      █"
  20. @ 7,36 say "███   █████"
  21. @ 1,20 TO 9,60 DOUBLE
  22. CENTER(1,"DISPLAY STRUCTURE")
  23.  
  24. * Present menu of dbf files
  25. dbfcnt = ADIR("*.dbf")
  26. DECLARE dbfs[dbfcnt]
  27. ADIR("*.dbf",dbfs)
  28. IF dbfcnt < 1
  29.    ?? CHR(7)
  30.    @ 0,0
  31.    @ 0,0 say "There are no dbf files in this directory." +;
  32.              " Press any key to continue."
  33.    INKEY(0)
  34.    @ 0,0
  35. ELSE
  36.    DECLARE dbfs[dbfcnt]
  37.  
  38.    * Load the array with the dbf names
  39.    adir("*.dbf",dbfs)
  40.  
  41.    DO WHILE .T.
  42.       * Offer user a menu of the dbf files and store the array
  43.       *   subscript of the choice in a variable
  44.       * Draw a box to contain the choices
  45.       @ 11,35 to 19,46
  46.       CENTER(21,"Highlight your choice and press <Enter>")
  47.       CENTER(22,"Press<ESC> to exit DS program")
  48.       subscpt = ACHOICE(12,36,18,45,dbfs)
  49.       IF subscpt = 0
  50.          EXIT
  51.       ENDIF
  52.  
  53.       * Get the choice
  54.       IF subscpt > 0 .and. subscpt <= dbfcnt
  55.          curfile = dbfs[subscpt]
  56.          * Chop off the extension
  57.          curfile = SUBSTR(curfile,1,AT(".",curfile)-1)
  58.          * Pad to a length of 8 with spaces
  59.          curfile = IIF((LEN(curfile)<8),(curfile +;
  60.             SPACE(8-LEN(curfile))),curfile)
  61.       ELSE 
  62.          curfile = SPACE(8)
  63.       ENDIF
  64.  
  65.       IF curfile != SPACE(8)
  66.          USE &curfile.   && Dot terminate macros to avoid errors
  67.          * Create a file containing the structure of the chosen
  68.          *   file
  69.          COPY TO &curfile..str STRUCTURE EXTENDED
  70.          USE &curfile..str
  71.          DECLARE fields[fcount()], heads[4]
  72.          * Fill the fields array with all the fieldnames from the
  73.          *    currently open file
  74.          * Note: Can also use AFIELDS() to fill the fields array
  75.          FOR i=1 TO fcount()
  76.             fields[i] = fieldname(i)
  77.          NEXT
  78.          * Define the column headings
  79.          heads[1] = "Field Name"
  80.          heads[2] = "Field Type"
  81.          heads[3] = "Field Width"
  82.          heads[4] = "No. of Decimals"
  83.          @ 11,0 CLEAR TO 24,79
  84.          * Draw a box to contain the table
  85.          @ 12,0 TO 23,79
  86.          CENTER(11,"Press <Enter> or <ESC> to exit")
  87.          DBEDIT(13,1,22,78,fields,.F.,.F.,heads)
  88.          CLOSE DATABASES
  89.          subscpt = 1
  90.          @ 11,0 CLEAR TO 24,79 
  91.       ENDIF
  92.    ENDDO
  93. ENDIF
  94. CLEAR
  95. RESTORE SCREEN FROM dispscrn
  96. RETURN
  97. ********************
  98. * Function to center a string on a given row.
  99. * Usage: Center(row#,expC)
  100.  
  101. FUNCTION Center
  102. PARAMETERS trow,in_string
  103. IF LEN(in_string)>=80
  104.    @ trow,0 SAY in_string
  105. ELSE 
  106.    @ trow,(80 - LEN(in_string))/2 SAY in_string
  107. ENDIF 
  108.  
  109. RETURN ("")
  110.