Anonymous user
Text processing/1: Difference between revisions
m
→{{header|REXX}}: added/changed whitespace and comments, simplified the COMMAS subroutine.
(jq) |
m (→{{header|REXX}}: added/changed whitespace and comments, simplified the COMMAS subroutine.) |
||
Line 2,923:
=={{header|REXX}}==
<lang rexx>/*REXX program to process instrument data from a data file. */
numeric digits 20 /*allow for bigger (precision) numbers.
ifid='READINGS.TXT' /*the name
ofid='READINGS.OUT' /*
grandSum=0 /*the grand sum of whole file. */
grandOKs=0
w=16 /*the width of fields when displayed. */
do recs=1 while lines(ifid)\==0 /*
rec=linein(ifid) /*read the next record (line)
parse var rec datestamp Idata /*pick off the dateStamp
sum=0
flg=0
OKs=0
do j=1 until Idata='' /*process the instrument data. */
parse var Idata data.j flag.j Idata
if flag.j>0 then do /*
OKs=OKs+1
sum=sum+data.j
if
end
end
else do /*process flagged data
flg=flg+1
end
end /*j*/
if OKs\==0 then avg=format(sum/OKs,,3)
else avg='[n/a]'
grandOKs=grandOKs+OKs
_=right(
grandSum=grandSum+sum
grandFlg=grandFlg+flg
if flg==0 then call sy datestamp ' average='_
else call sy datestamp ' average='_ ' flagged='right(flg,2)
end /*recs*/
recs=recs-1 /*adjust for reading
if grandOKs\==0 then Gavg=format(
else Gavg='[n/a]'
call sy
call sy copies('═',60)
call sy ' records read:' right(
call sy ' grand sum:' right(
call sy ' grand average:' right(
call sy ' grand OK data:' right(
call sy ' grand flagged:' right(
if Lflag\==0 then call sy ' longest flagged:' right(
▲call sy ' longest flagged:' right(comma(longFlag),w) " ending at " longdate
call sy copies('═',60)
exit /*stick a fork in it, we're all done. */
/*────────────────────────────────────────────────────────────────────────────*/
/*────────────────────────────────────────────────────────────────────────────*/
sy: say arg(1); call lineout ofid,arg(1); return</lang>
'''output''' when using the default input file:
▲ e=verify(n,#'0',,verify(n,#"0.",'M'))-p-1;end
▲ do j=e to b by -p while k<t;_=insert(c,_,j);k=k+1;end;return _</lang>
▲<pre style="height:40ex;overflow:scroll">
∙
∙
|