Word wrap: Difference between revisions
Content added Content deleted
(→{{header|REXX}}: added original version.) |
(→version 0: found an older version. -- ~~~~) |
||
Line 1,472: | Line 1,472: | ||
=={{header|REXX}}== |
=={{header|REXX}}== |
||
===version 0=== |
===version 0=== |
||
This version was the original |
This version was the original (of version 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). */ |
<lang rexx>/*REXX pgm reads a file and displays it (with word wrap to the screen). */ |
||
parse arg iFID width |
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.*/ |
|||
@=@ linein(iFID) /*append the file's text to @ */ |
|||
end /*j*/ |
|||
$= |
$= |
||
do k=1 for words(@); |
do k=1 for words(@); x=word(@,k) /*parse until text (@) exhausted.*/ |
||
_=$ x |
_=$ x /*append it to the money and see.*/ |
||
if length(_)>width then |
if length(_)>width then do /*words exceeded the width? */ |
||
say $ /*display what we got so far. */ |
|||
⚫ | |||
⚫ | |||
end |
|||
$=_ /*append this word to the output.*/ |
|||
⚫ | |||
/*──────────────────────────────────TELL subroutine─────────────────────*/ |
|||
if $\=='' then say $ /*handle any residual words. */ |
|||
/*stick a fork in it, we're done.*/</lang> |
|||
⚫ | |||
⚫ | |||
return /*go back and keep truckin'. */</lang> |
|||
⚫ | |||
===version 1=== |
===version 1=== |