RosettaCodeData/Task/Word-wrap/PL-I/word-wrap.pli
Ingy döt Net 776bba907c Sync
2013-10-27 22:24:23 +00:00

32 lines
786 B
Text

*process source attributes xref or(!);
ww: proc Options(main);
/*********************************************************************
* 21.08-2013 Walter Pachl derived from REXX version 2
*********************************************************************/
Dcl in record input;
Dcl out record output;
On Endfile(in) z=' ';
Dcl z char(32767) Var;
Dcl s char(32767) Var Init('');
dcl o Char(200) Var;
Dcl (i,w,p) Bin Fixed(31) Init(0);
w=72;
Read File(in) Into(z);
s=z;
Do Until(s='');
Do i=w+1 to 1 by -1;
If substr(s,i,1)='' Then Leave;
End;
If i=0 Then
p=index(s,' ');
Else
p=i;
o=left(s,p);
Write file(out) From(o);
s=substr(s,p+1);
If length(s)<200 Then Do;
Read File(in) Into(z);
s=s!!z;
End;
End;
End;