Word wrap: Difference between revisions

Content added Content deleted
(→‎{{header|REXX}}: added original version.)
(→‎version 0: found an older version. -- ~~~~)
Line 1,472:
=={{header|REXX}}==
===version 0===
This version was the original and(of itversion 1) and has no error checking and only does left-margin justification.
<lang rexx>/*REXX pgm reads a file and displays it (with word wrap to the screen). */
parse arg iFID width . /*get optional arguments from CL.*/
@= /*nullify the text (so far). */
do j=0 while lines(iFID)\==0 /*read from the file until E-O-F.*/
@=@ linein(iFID) /*append the file's text to @ */
end /*j*/
$=
do k=1 for words(@); x=word(@,k) /*parse until text (@) exhausted.*/
_=$ x /*append it to the money and see.*/
if length(_)>width then calldo tell /*word(s)words exceeded the width? */
$=_ say $ /*thedisplay newwhat wordswe are OKgot so far. */
_=x _=x /*handleoverflow anyfor wordthe overflownext line. */
end /*k*/
call tell /*handle any residual words. */end
exit $=_ /*stick aappend forkthis inword it,to we'rethe doneoutput.*/
end /*k*/
/*──────────────────────────────────TELL subroutine─────────────────────*/
tell: if $\=='' then returnsay $ /*first word may be too long /*handle any residual words. */
say $ /*showstick anda tellfork in it, orwe're write──►file?done.*/</lang>
'''output''' is the same as version 1 using the &nbsp; '''L'''eft &nbsp; option (the default).
_=x /*handle any word overflow. */
return /*go back and keep truckin'. */</lang>
'''output''' is the same as version 1 using the &nbsp; '''L'''eft &nbsp; option (the default).
 
===version 1===