Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
37
Task/Align-columns/PL-I/align-columns.pli
Normal file
37
Task/Align-columns/PL-I/align-columns.pli
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
declare text character (300) varying;
|
||||
declare word character (20) varying;
|
||||
declare justification character (1);
|
||||
declare k fixed binary;
|
||||
declare input file, output file output;
|
||||
|
||||
open file (input) title ( '/CENTER.DAT,type(text),recsize(1000)' );
|
||||
open file (output) title ( '/OUT.TXT,type(text),recsize(1000)' );
|
||||
on endfile (input) stop;
|
||||
|
||||
display ('Specify whether justification is left, centered, or right');
|
||||
display ('Reply with a single letter: L, C, or R');
|
||||
get edit (justification) (A(1));
|
||||
|
||||
do forever;
|
||||
get file (input) edit (text) (L);
|
||||
put skip list (text);
|
||||
text = trim(text, '$', '$');
|
||||
do until (k = 0);
|
||||
k = index(text, '$');
|
||||
if k = 0 then /* last word in line */
|
||||
word = text;
|
||||
else
|
||||
do;
|
||||
word = substr(text, 1, k-1);
|
||||
text = substr(text, k);
|
||||
text = trim(text, '$');
|
||||
end;
|
||||
select (justification);
|
||||
when ('C', 'c') word = center(word, maxlength(word));
|
||||
when ('R', 'r') word = right (word, maxlength(word));
|
||||
otherwise ; /* The default is left adjusted. */
|
||||
end;
|
||||
put file (output) edit (word) (a(maxlength(word)));
|
||||
end;
|
||||
put file (output) skip;
|
||||
end;
|
||||
Loading…
Add table
Add a link
Reference in a new issue