File size distribution: Difference between revisions

Content added Content deleted
m (added a ;Task: section header, added whitespace before the table-of-contents (TOC), separated suggestions and a query from the task's requirements..)
(→‎{{header|REXX}}: added support for an alternative comma, added a programming note (before the output section).)
Line 430: Line 430:
_=linein(dirOUT); if left(_, 1)==' ' then iterate /*process data. */
_=linein(dirOUT); if left(_, 1)==' ' then iterate /*process data. */
parse upper var _ dat tim sz . /*uppercase suffix*/
parse upper var _ dat tim sz . /*uppercase suffix*/
if pos('/', dat) ==0 | pos(":", tim)==0 then iterate /*validate dat&tim*/
if pos(',', sz) \==0 then sz=space( translate(sz, , ",ÿ"), 0) /*SZ has commas? */
if pos(',', sz) \==0 then sz=space( translate(sz, , ","), 0) /*SZ has commas? */
if \datatype(sz,'W') then do; #=left(sz, length(sz) - 1) /*SZ has a suffix?*/
if \datatype(#,'N') then iterate /*Meat ¬ numeric? */
if \datatype(sz,'W') then do; #=left(sz, length(sz) - 1) /*SZ has a suffix?*/
if \datatype(#,'N') then iterate /*Meat ¬ numeric? */
sfx=right(sz, 1) /*get the suffix. */
sfx= right(sz, 1) /*get the suffix. */
sz=#*1024**pos(sfx,'KMGTPEZYX')/1 /*compute true val*/
sz=# * 1024 **pos(sfx,'KMGT')/1 /*compute true val*/
end
end
$=$ + sz /*keep a running total for the filesize*/
$=$ + sz /*keep a running total for the filesize*/
Line 468: Line 467:
/*──────────────────────────────────────────────────────────────────────────────────────*/
/*──────────────────────────────────────────────────────────────────────────────────────*/
commas: parse arg _; do jc=length(_)-3 to 1 by -3; _=insert(',', _, jc); end; return _</lang>
commas: parse arg _; do jc=length(_)-3 to 1 by -3; _=insert(',', _, jc); end; return _</lang>
This REXX program makes use of &nbsp; '''LINESIZE''' &nbsp; REXX program (or BIF) which is used to determine the screen width (or linesize) of the terminal (console).
<br>The &nbsp; '''LINESIZE.REX''' &nbsp; REXX program is included here &nbsp; ──► &nbsp; [[LINESIZE.REX]].<br>

{{out|output|text=&nbsp; when using the default input: &nbsp; (which in this case was the &nbsp; '''C:''' &nbsp; drive.)}}
{{out|output|text=&nbsp; when using the default input: &nbsp; (which in this case was the &nbsp; '''C:''' &nbsp; drive.)}}
<pre>
<pre>