Jump to content

Word wrap: Difference between revisions

1,586 bytes added ,  10 years ago
→‎{{header|REXX}}: added original version.
m (→‎version 1: increased height of 1st viewing window. -- ~~~~)
(→‎{{header|REXX}}: added original version.)
Line 1,471:
 
=={{header|REXX}}==
===version 0===
This version was the original and it 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 call tell /*word(s) exceeded the width? */
$=_ /*the new words are OK so far. */
end /*k*/
call tell /*handle any residual words. */
exit /*stick a fork in it, we're done.*/
/*──────────────────────────────────TELL subroutine─────────────────────*/
tell: if $=='' then return /*first word may be too long. */
say $ /*show and tell, or write──►file?*/
_=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===
The input for this program is in a file (named LAWS.TXT).
Cookies help us deliver our services. By using our services, you agree to our use of cookies.