Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
54
Task/Text-processing-1/PL-I/text-processing-1.pli
Normal file
54
Task/Text-processing-1/PL-I/text-processing-1.pli
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
text1: procedure options (main); /* 13 May 2010 */
|
||||
|
||||
declare line character (2000) varying;
|
||||
declare 1 pairs(24),
|
||||
2 value fixed (10,4),
|
||||
2 flag fixed;
|
||||
declare date character (12) varying;
|
||||
declare no_items fixed decimal (10);
|
||||
declare (nv, sum, line_no, ndud_values, max_ndud_values) fixed;
|
||||
declare (i, k) fixed binary;
|
||||
declare in file input;
|
||||
|
||||
open file (in) title ('/TEXT1.DAT,TYPE(TEXT),RECSIZE(2000)' );
|
||||
|
||||
on endfile (in) go to finish_up;
|
||||
|
||||
line_no = 0;
|
||||
loop:
|
||||
do forever;
|
||||
get file (in) edit (line) (L);
|
||||
/* put skip list (line); */
|
||||
line = translate(line, ' ', '09'x);
|
||||
line_no = line_no + 1;
|
||||
line = trim(line);
|
||||
no_items = tally(line, ' ') - tally(line, ' ') + 1;
|
||||
if no_items ^= 49 then
|
||||
do; put skip list ('There are not 49 items on this line'); iterate loop; end;
|
||||
k = index(line, ' '); /* Find the first blank in the line. */
|
||||
date = substr(line, 1, k);
|
||||
line = substr(line, k) || ' ';
|
||||
on conversion go to loop;
|
||||
get string (line) list (pairs);
|
||||
sum, nv, ndud_values, max_ndud_values = 0;
|
||||
do i = 1 to 24;
|
||||
if flag(i) > 0 then
|
||||
do; sum = sum + value(i); nv = nv + 1;
|
||||
ndud_values = 0; /* reset the counter of dud values */
|
||||
end;
|
||||
else
|
||||
do; /* we have a dud reading. */
|
||||
ndud_values = ndud_values + 1;
|
||||
if ndud_values > max_ndud_values then
|
||||
max_ndud_values = ndud_values;
|
||||
end;
|
||||
end;
|
||||
if nv = 0 then iterate;
|
||||
put skip list ('Line ' || trim(line_no) || ' average=', divide(sum, nv, 10,4) );
|
||||
if max_ndud_values > 0 then
|
||||
put skip list ('Maximum run of dud readings =', max_ndud_values);
|
||||
end;
|
||||
|
||||
finish_up:
|
||||
|
||||
end text1;
|
||||
Loading…
Add table
Add a link
Reference in a new issue