Word wrap: Difference between revisions
Content added Content deleted
m (→version 1: increased height of 1st viewing window. -- ~~~~) |
(→{{header|REXX}}: added original version.) |
||
Line 1,471: | Line 1,471: | ||
=={{header|REXX}}== |
=={{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 '''L'''eft option (the default). |
|||
===version 1=== |
===version 1=== |
||
The input for this program is in a file (named LAWS.TXT). |
The input for this program is in a file (named LAWS.TXT). |