home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 13 / AACD13.ISO / AACD / Utilities / QuickFile / ARexx / FieldLengths.quickfile < prev    next >
Text File  |  2000-04-26  |  2KB  |  78 lines

  1. /*
  2. $VER: FieldLengths.quickfile 1.6 (26 Apr 2000  12:54:01) By M Andre Z Eckenrode
  3.  
  4. Finds the maximum USED length of each field in all records in the current
  5. index; reports the results in a REQMSG requester. May be useful prior to
  6. creating a new LIST view with a minimum of excess line length.
  7.  
  8. Requires QuickFile v3.24 or higher and the following external function macros:
  9.  
  10.   ProgressWin.quickfile
  11.   GetViewWin.quickfile
  12.  
  13. */
  14.  
  15. req.y = 43 /* Max text lines in requester; change as desired */
  16.  
  17. /*
  18. The value above represents the maximum number of lines of text to fit in
  19. QuickFile's REQMSG requester, and only makes a difference if the number of
  20. fields defined for the database this macro is being run on exceeds it. Change
  21. as desired to configure maximum requester height. I.E.,<43> for an 856x600
  22. screen and 12 point font. If the requester height exceeds the height of the
  23. current screen, a separate screen is opened with the necessary height to
  24. display it (screen scrolling may be required to view the entire requester).
  25. */
  26.  
  27. options results
  28.  
  29. numrecs
  30. recs = result
  31. soi = -1*(recs-1)
  32. next '"'soi'"'
  33.  
  34. query field fld
  35. do i = 1 to fld.0
  36.     fld.i.max = 0
  37. end
  38.  
  39. lf = d2c(10)
  40. esc = d2c(27)
  41. line = '  Working...Record '
  42. winspec = 'arexx/progresswin'(length(line)+(2*length(recs))+4,'FieldLengths.quickfile')
  43. call open(1win,winspec,'w')
  44. call writech(1win,esc'[0 p'lf||line)
  45.  
  46. do ii = 1 to recs
  47.     call writech(1win,esc'[2;20f'ii 'of' recs)
  48.     do i = 1 to fld.0
  49.         getfield fld.i
  50.         fld.i.max = max(fld.i.max,length(result))
  51.     end
  52.     next
  53. end
  54.  
  55. call close(1win)
  56.  
  57. if req.y > 15 then req.y = req.y-2
  58. cols = (fld.0%req.y)+sign(fld.0//req.y)
  59. lines = (fld.0%cols)+sign(fld.0//cols)
  60.  
  61. body = ''
  62. str.1 = left('Field',12)'Max'
  63. str.2 = copies('~',15)
  64. do i = 1 to 2
  65.     do ii = 1 to cols
  66.         body = body||str.i||copies('  ',sign(cols-ii))copies(lf,-1*((sign(cols-ii))-1))
  67.     end
  68. end
  69.  
  70. do i = 1 to lines
  71.     do ii = 1 to cols
  72.         f = ((ii-1)*lines)+i
  73.         body = body||copies(left(fld.f,12)right(fld.f.max,3),sign(max(0,fld.0-f+1)))copies(' ',15*sign(max(0,f-fld.0)))copies('  ',sign(cols-ii))copies(lf,max(0,-1*((sign(cols-ii))-1)*sign((i*ii)+(cols-ii))))
  74.     end
  75. end
  76.  
  77. reqmsg '"'body'"'
  78.