Anonymous user
File size distribution: Difference between revisions
m
→{{header|REXX}}: added/changed whitespace and comments, simplified the inner DO loop by eliding the use of SELECT.
SqrtNegInf (talk | contribs) (Added Perl example) |
m (→{{header|REXX}}: added/changed whitespace and comments, simplified the inner DO loop by eliding the use of SELECT.) |
||
Line 457:
parse arg ds . /*obtain optional argument from the CL.*/
parse source . . path . /* " the path of this REXX program.*/
fID= substr(path, 1 + lastpos('\', path) )
parse var fID fn '.' /* " just the pure filename of pgm.*/
sw=max(79, linesize() - 1) /* " terminal width (linesize) - 1.*/
Line 463:
'DIR' ds '/s /-c /a-d >' work /*do (DOS) DIR cmd for a data structure*/
call linein 0, 1 /*open output file, point to 1st record*/
maxL= 0;
$=0 /*$: total bytes used by files found. */
do while lines(work)\==0; _= linein(work)
if left(_, 1)==' ' then iterate /*Is the record not legitimate? Skip. */
parse upper var _ . . sz . /*uppercase suffix*/
if \datatype(sz,'W') then do; #= left(sz, length(sz) - 1)
if \datatype(#,
sz= # * 1024 ** pos( right(sz, 1), 'KMGTPEZYXWVU') / 1
end /* [↑] use suffix*/
$= $ + sz
if sz==0 then L=
else L= length(sz)
g= g + 1
maxL= max(L, maxL)
@.L= @.L + 1
end /*j*/ /* [↑] categories: split by log ten.*/
Line 485:
mC=0 /*mC: the maximum count for any range.*/
do t=1 to 2 /*T==1 is used to find the max count.*/
do k=0 to maxL; mC= max(mC, @.k); if t==1 then iterate
say y || right( commas(@.k), 11) copies('─', max(1, (@.k / mC * sw % 1) - LHdr) )
end /*k*/
|