Word wrap: Difference between revisions
Content added Content deleted
(→{{header|C}}: new) |
m (→{{header|REXX}}: added/changed comments, added whitespace. -- ~~~~) |
||
Line 549: | Line 549: | ||
<br>No hyphenation (or de-hyphenation) is attempted. |
<br>No hyphenation (or de-hyphenation) is attempted. |
||
<br>Words longer than the width of the output are acceptable and are shown, a simple change could be made to issue a notification. |
<br>Words longer than the width of the output are acceptable and are shown, a simple change could be made to issue a notification. |
||
⚫ | |||
<lang rexx> |
|||
arg justify width . /*───────────JUSTIFY─────────────*/ |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
just=left(justify,1) /*only use first capital letter. */ |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
just=left(justify,1) /*only use 1st capital letter*/ |
|||
⚫ | |||
⚫ | |||
⚫ | |||
txt="Diplomacy is the art of saying 'Nice Doggy' until", |
txt="Diplomacy is the art of saying 'Nice Doggy' until", |
||
"you can find a rock. ─── Will Rodgers" |
"you can find a rock. ─── Will Rodgers" |
||
⚫ | |||
/*─────────────────────────────────────where da rubber meets da road*/ |
|||
⚫ | |||
do k=1 for words(txt) |
do k=1 for words(txt); x=word(txt,k) /*parse 'til we exhaust the TXT. */ |
||
_=$ x /*append it to da money and see. */ |
|||
⚫ | |||
$=_ /*the new words are OK so far. */ |
|||
⚫ | |||
$=_ /*the new words are OK so far*/ |
|||
end |
end |
||
call tell /*handle any residual words. */ |
call tell /*handle any residual words. */ |
||
exit /* |
exit /*stick a fork in it, we're done.*/ |
||
/*──────────────────────────────────TELL subroutine─────────────────────*/ |
|||
⚫ | |||
/*─────────────────────────────────────TELL subroutine──────────────*/ |
|||
⚫ | |||
select |
select |
||
when just=='B' then $=justify($,width) /* |
when just=='B' then $=justify($,width) /*◄────both────►*/ |
||
when just=='C' then $= center($,width) /* |
when just=='C' then $= center($,width) /* ◄centered► */ |
||
when just=='R' then $= right($,width) /* |
when just=='R' then $= right($,width) /*──────► right */ |
||
otherwise $= strip($) /*left |
otherwise $= strip($) /*left ◄────────*/ |
||
end |
end /*select*/ |
||
say $ /*show |
say $ /*show and tell, or write──►file?*/ |
||
_=x /*handle any word overflow. */ |
_=x /*handle any word overflow. */ |
||
return /*go back and keep truckin'. */ |
return /*go back and keep truckin'. */</lang> |
||
</lang> |
|||
The input file: |
The input file: |
||
<pre style="height:15ex;overflow:scroll"> |
<pre style="height:15ex;overflow:scroll"> |