home *** CD-ROM | disk | FTP | other *** search
/ Lion Share / lionsharecd.iso / utils_mz / v10n14.zip / FIELDSIZ.PRG < prev    next >
Text File  |  1991-07-11  |  1KB  |  47 lines

  1. * PROGRAM:  FIELDSIZ.PRG
  2. * PURPOSE:  Find the smallest size a character field can be
  3. *           without losing any current data.
  4. *
  5. * REMARKS:  You can call this program either from the dot prompt
  6. *           or from inside another program.
  7. *
  8. * COMMAND:   DO FIELDSIZ WITH 'FILENAME' (dBASE, FoxBASE+...)
  9. *   OR       FIELDSIZ FILENAME if compiled with Clipper
  10.  
  11. PARAMETERS filename
  12. CLEAR
  13. SET TALK OFF
  14. SET STATUS OFF
  15. CLOSE DATABASES
  16. SELECT 1
  17. USE &filename
  18. ? "File: "+filename+".DBF"
  19. ? "Optimum structure:"
  20. ?
  21. msavtot=0
  22. maux=1
  23. DO WHILE LEN(FIELD(maux))>0
  24.    IF TYPE(FIELD(maux))<>'C'    && Check if the field is of Type "Char"
  25.       maux=maux+1               && If not, goto next field
  26.       LOOP
  27.    ENDIF
  28.    mtotal=0
  29.    mname=FIELD(maux)
  30.    GOTO TOP
  31.    DO WHILE .NOT. EOF()
  32.       IF LEN(TRIM(&mname))>mtotal
  33.          mtotal=LEN(TRIM(&mname))
  34.       ENDIF
  35.       SKIP
  36.    ENDDO
  37.    msaved=(LEN(&mname)-mtotal)*RECCOUNT()
  38.    msavtot=msavtot+msaved
  39.    msg=IIF(msaved>0," bytes to save"," no change on this field")
  40.    ? RIGHT(SPACE(10)+TRIM(FIELD(maux)),11),mtotal,STR(msaved)+msg
  41.    maux=maux+1
  42. ENDDO
  43. ?
  44. ? "Total number of bytes that can be saved: " + LTRIM(STR(msavtot))
  45. CLOSE DATABASES
  46. RETURN
  47.