Word wrap: Difference between revisions

Content added Content deleted
(→‎version 0: found an older version. -- ~~~~)
(→‎version 0: fixed showing an extra blank before 1st line of text. -- ~~~~)
Line 1,476: Line 1,476:
parse arg iFID width /*get optional arguments from CL.*/
parse arg iFID width /*get optional arguments from CL.*/
@= /*nullify the text (so far). */
@= /*nullify the text (so far). */
do j=0 while lines(iFID)\==0 /*read from the file until E-O-F.*/
do j=0 while lines(iFID)\==0 /*read from the file until E-O-F.*/
@=@ linein(iFID) /*append the file's text to @ */
@=@ linein(iFID) /*append the file's text to @ */
end /*j*/
end /*j*/
$=word(@,1)
$=
do k=1 for words(@); x=word(@,k) /*parse until text (@) exhausted.*/
do k=2 for words(@)-1; x=word(@,k) /*parse until text (@) exhausted.*/
_=$ x /*append it to the money and see.*/
_=$ x /*append it to the money and see.*/
if length(_)>width then do /*words exceeded the width? */
if length(_)>width then do /*words exceeded the width? */
say $ /*display what we got so far. */
say $ /*display what we got so far. */
_=x /*overflow for the next line. */
_=x /*overflow for the next line. */
end
end
$=_ /*append this word to the output.*/
$=_ /*append this word to the output.*/
end /*k*/
end /*k*/
if $\=='' then say $ /*handle any residual words. */
if $\=='' then say $ /*handle any residual words. */
/*stick a fork in it, we're done.*/</lang>
/*stick a fork in it, we're done.*/</lang>