home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / database / dbadv.zip / FILESTAT.PRG < prev    next >
Text File  |  1986-02-25  |  2KB  |  73 lines

  1. SET talk OFF
  2. ERASE
  3. *set up the string macros
  4. DO string
  5. *
  6. *get the file and fields to process
  7. ACCEPT "File name " TO FILE
  8. ACCEPT "Field name(s) " TO string
  9. USE &FILE
  10. *
  11. *process each field name in turn
  12. &firstchar
  13. DO WHILE .not. &endstring
  14.   *
  15.   * go to the next field name
  16.   DO word
  17.   STORE newstring TO FIELD
  18.   *
  19.   *initialize the variables to be used for statistics
  20.   STORE "len(trim(&field))" TO length
  21.   STORE 0 TO blanks
  22.   STORE 0 TO TOTAL
  23.   STORE 0 TO records
  24.   *
  25.   * make the first record both maximum and minimum
  26.   GOTO TOP
  27.   STORE &length TO maximum
  28.   STORE &length TO minimum
  29.   *
  30.   DO WHILE .not. eof
  31.     *
  32.     DO CASE
  33.         * the current record is blank
  34.       CASE &length = 1 .AND. &FIELD = " " 
  35.         STORE blanks + 1 TO blanks
  36.         *
  37.         * the current record is the new maximum
  38.       CASE &length > maximum
  39.         STORE &length TO maximum
  40.         *
  41.         * the current record is the new minimum
  42.       CASE &length < minimum
  43.         STORE &length TO minimum
  44.     ENDCASE 
  45.     *
  46.     * accumulate the total charactrs and records so far
  47.     STORE TOTAL + &length TO TOTAL
  48.     STORE records + 1 TO records
  49.     *
  50.     SKIP
  51.   ENDDO WHILE .not. eof 
  52.   *
  53.   *print the results for the current record
  54.   ?
  55.   ? "Statistics for &field" 
  56.   ?
  57.   ? "Number of records " , records
  58.   ? "Blank records     " , blanks
  59.   ? "Field length      " , len(&FIELD)
  60.   ? "Maximum field     " , maximum
  61.   ? "Minimum field     " , minimum
  62.   ? "Percent usage     " , (TOTAL/(len(&FIELD)*records))* 100.00
  63.   *
  64. ENDDO WHILE .not. &endstring 
  65. *
  66. * clean up
  67. RELEASE FILE, FIELD, string,newstring,length,blanks, maximum,;
  68. minimum, TOTAL, records
  69. SET talk ON
  70. ****************************************************************
  71. ****************************************************************
  72. ****************************************************************
  73.