/* $VER: FieldLengths.quickfile 1.6 (26 Apr 2000 12:54:01) By M Andre Z Eckenrode Finds the maximum USED length of each field in all records in the current index; reports the results in a REQMSG requester. May be useful prior to creating a new LIST view with a minimum of excess line length. Requires QuickFile v3.24 or higher and the following external function macros: ProgressWin.quickfile GetViewWin.quickfile */ req.y = 43 /* Max text lines in requester; change as desired */ /* The value above represents the maximum number of lines of text to fit in QuickFile's REQMSG requester, and only makes a difference if the number of fields defined for the database this macro is being run on exceeds it. Change as desired to configure maximum requester height. I.E.,<43> for an 856x600 screen and 12 point font. If the requester height exceeds the height of the current screen, a separate screen is opened with the necessary height to display it (screen scrolling may be required to view the entire requester). */ options results numrecs recs = result soi = -1*(recs-1) next '"'soi'"' query field fld do i = 1 to fld.0 fld.i.max = 0 end lf = d2c(10) esc = d2c(27) line = ' Working...Record ' winspec = 'arexx/progresswin'(length(line)+(2*length(recs))+4,'FieldLengths.quickfile') call open(1win,winspec,'w') call writech(1win,esc'[0 p'lf||line) do ii = 1 to recs call writech(1win,esc'[2;20f'ii 'of' recs) do i = 1 to fld.0 getfield fld.i fld.i.max = max(fld.i.max,length(result)) end next end call close(1win) if req.y > 15 then req.y = req.y-2 cols = (fld.0%req.y)+sign(fld.0//req.y) lines = (fld.0%cols)+sign(fld.0//cols) body = '' str.1 = left('Field',12)'Max' str.2 = copies('~',15) do i = 1 to 2 do ii = 1 to cols body = body||str.i||copies(' ',sign(cols-ii))copies(lf,-1*((sign(cols-ii))-1)) end end do i = 1 to lines do ii = 1 to cols f = ((ii-1)*lines)+i 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)))) end end reqmsg '"'body'"'