Word wrap: Difference between revisions

Content added Content deleted
(GP)
(→‎{{header|REXX}}: added the REXX language. -- ~~~~)
Line 151: Line 151:
| has seen so much, was astonished whenever
| has seen so much, was astonished whenever
| it shone in her face.
| it shone in her face.
</pre>

=={{header|REXX}}==
The input for this program is in a file (named LAWS.TXT).
<br>The default width of the output is ½ of the current terminal width, or
<br>if the terminal width is indeterminable, then 40 is used.
<br>If the specified width is negative, then the output is shown justified (with the absolute value of width).
<lang rexx>
/*REXX pgm reads a file and displays it (with word wrap to the screen). */

parse arg width fileID .; if fileID='' then fileID='LAWS.TXT'
if width=='' then width=linesize()%2; if width==0 then width=40
if \datatype(width,'W') then call err "WIDTH (1st arg) isn't an integer."
txt=; $=; justify=width<0; width=abs(width)

do j=0 while lines(fileID)\==0 /*read from until until E-O-F. */
txt=txt linein(fileID)
end

txt=space(txt)
if j==0 then call err 'file' fileID "not found."
if txt=='' then call err 'file' fileID "is empty."

do k=1 for words(txt)
x=word(txt,k)
_=$ x
if length(_)>width then call tell
$=_
end

if $\=='' then call tell /*handle any residual words. */
exit

tell: if justify then say justify($,width)
else say strip($)
_=x
return
err: say; say '***error!***'; say; say arg(1); say; say arg(1);say;exit 13
</lang>
The input file:
<pre style="height:15ex;overflow:scroll">
────────── Computer programming laws ──────────
The Primal Scenario -or- Basic Datum of Experience:
∙ Systems in general work poorly or not at all.
∙ Nothing complicated works.
∙ Complicated systems seldom exceed 5% efficiency.
∙ There is always a fly in the ointment.
The Fundamental Theorem:
∙ New systems generate new problems.
Occam's Razor:
∙ Systems should not be unnecessarily multiplied.
The Law of Conservation of Energy:
∙ The total amount of energy in the universe is constant.
∙ Systems operate by redistributing energy into different forms and into accumulations of different sizes.
Laws of Growth:
∙ Systems tend to grow, and as they grow, they encroach.
The Big-Bang Theorem of Systems-Cosmology:
∙ Systems tend to expand to fill the known universe.
Parkinson's Extended Law:
∙ The system itself tends to expand at 5-6% per annum.
The Generalized Uncertainty Principle:
∙ Systems display antics.
∙ Complicated systems produce unexpected outcomes.
∙ The total behavior of large systems cannot be predicted.
The Non-Addivity Theorem of Systems-Behavior -or- Climax Design Theorem:
∙ A large system, produced by expanding the dimensions of a smaller system, does not behave like the smaller system.
LeChateliers's Principle:
∙ Complex systems tend to oppose their own proper function.
∙ Systems get in the way.
∙ The system always kicks back.
∙ Positive feedback is dangerous.
Functionary's Falsity:
∙ People in systems do not do what the system says they are doing.
∙ The function performed by a system is not operationally identical to the function of the same name performed by a man.
∙ A function performed by a larger system is not operationally identical to the function of the same name performed by a smaller system.
The Fundamental Law of Administrative Workings:
∙ Things are what they are reported to be.
∙ The real world is whatever is reported to the system.
∙ If it isn't official; it didn't happen.
∙ If it's made in Detriot, it must be an automobile.
∙ A system is no better than its sensory organs.
∙ To those within a system, the outside reality tends to pale and disappear.
∙ Systems attract systems-people.
∙ For every human system, there is a type of person adapted to thrive on it or in it.
∙ The bigger the system, the narrower and more specialized the interface with individuals.
Administrator's Anxiety:
∙ Pushing on the systems doesn't help. It just makes things worse.
∙ A complex system cannot be "made" to work. It either works or it doesn't.
∙ A simple system, designed from scratch, sometimes works.
∙ A simple system may or may not work.
∙ Some complex systems actually work.
∙ If a system is working, leave it alone.
∙ A complex system that works is invariably found to have evolved from a simple system that works.
∙ A complex system designed from scratch never works and cannot be patched up to make it work. You have to start over, beginning with a working simple system.
∙ Programs never run the first time.
∙ Complex programs never run.
∙ Anything worth doing once will probably have to be done twice.
The Functional indeterminancy Theorem:
∙ In complex systems, malfunction and even total nonfunction may not be detectable for long periods, if ever.
The Kantian Hypothesis -or- Know-Nothing Theorem:
∙ Large complex systems are beyond human capacity to evaluate.
The Newtonian Lay of Systems-Inertia:
∙ A system that performs a certain way will continue to operate in that way regardless of the need of of changed conditions.
∙ A system continues to do its thing, regardless of need.
∙ Systems develop goals of their own the instant they come into being.
∙ Intrasystem goals come first.
Failure-Mode Theorems:
∙ Complex systems usually operate in failure mode.
∙ A complex system can fail in a infinite number of ways.
∙ If anything can go wrong, it will.
∙ The mode of failure of a complex system cannot ordinarily be predicted from its structure.
∙ The crucial variables are discovered by accident.
∙ The larger the system, the greater the probability of unexpected failure.
∙ "Success" or "function" in any system may be failure in the larger or smaller systems to which the system is connected.
∙ In setting up a new system, tread softly. You may be disturbing another system that is actually working.
The Fail-Safe Theorem:
∙ When a fail-safe system fails, it fails by failing to fail safe.
∙ Complex systems tend to produce complex responses (not solutions) to problems.
∙ Great advances are not produced by systems designed to produce great advances.
∙ Loose systems last longer and work better.
∙ Efficient systems are dangerous to themselves and to others.
The Vector Theory of Systems:
∙ Systems run better when designed to run downhill.
∙ Systems aligned with human motivational vectors will sometimes work. Systems opposing such vectors work poorly or not at all.
Advanced Systems Theories:
∙ Everything is a system.
∙ Everything is a part of a larger system.
∙ The universe is infinitely systematized, both upward [larger systems] and downward [smaller systems].
∙ All systems are infinitely complex. (The illusion of simplicity comes from focusing attention on one or a few variables.)
∙ Parameters are variables travelling under an assumed name.
</pre>
Output when specifying: <tt> 155 </tt>
<pre style="height:15ex;overflow:scroll">
────────── Computer programming laws ────────── The Primal Scenario -or- Basic Datum of Experience: ∙ Systems in general work poorly or not at all. ∙
Nothing complicated works. ∙ Complicated systems seldom exceed 5% efficiency. ∙ There is always a fly in the ointment. The Fundamental Theorem: ∙ New
systems generate new problems. Occam's Razor: ∙ Systems should not be unnecessarily multiplied. The Law of Conservation of Energy: ∙ The total amount of
energy in the universe is constant. ∙ Systems operate by redistributing energy into different forms and into accumulations of different sizes. Laws of
Growth: ∙ Systems tend to grow, and as they grow, they encroach. The Big-Bang Theorem of Systems-Cosmology: ∙ Systems tend to expand to fill the known
universe. Parkinson's Extended Law: ∙ The system itself tends to expand at 5-6% per annum. The Generalized Uncertainty Principle: ∙ Systems display antics.
∙ Complicated systems produce unexpected outcomes. ∙ The total behavior of large systems cannot be predicted. The Non-Addivity Theorem of Systems-Behavior
-or- Climax Design Theorem: ∙ A large system, produced by expanding the dimensions of a smaller system, does not behave like the smaller system.
LeChateliers's Principle: ∙ Complex systems tend to oppose their own proper function. ∙ Systems get in the way. ∙ The system always kicks back. ∙ Positive
feedback is dangerous. Functionary's Falsity: ∙ People in systems do not do what the system says they are doing. ∙ The function performed by a system is
not operationally identical to the function of the same name performed by a man. ∙ A function performed by a larger system is not operationally identical
to the function of the same name performed by a smaller system. The Fundamental Law of Administrative Workings: ∙ Things are what they are reported to be.
∙ The real world is whatever is reported to the system. ∙ If it isn't official; it didn't happen. ∙ If it's made in Detriot, it must be an automobile. ∙ A
system is no better than its sensory organs. ∙ To those within a system, the outside reality tends to pale and disappear. ∙ Systems attract systems-people.
∙ For every human system, there is a type of person adapted to thrive on it or in it. ∙ The bigger the system, the narrower and more specialized the
interface with individuals. Administrator's Anxiety: ∙ Pushing on the systems doesn't help. It just makes things worse. ∙ A complex system cannot be "made"
to work. It either works or it doesn't. ∙ A simple system, designed from scratch, sometimes works. ∙ A simple system may or may not work. ∙ Some complex
systems actually work. ∙ If a system is working, leave it alone. ∙ A complex system that works is invariably found to have evolved from a simple system
that works. ∙ A complex system designed from scratch never works and cannot be patched up to make it work. You have to start over, beginning with a working
simple system. ∙ Programs never run the first time. ∙ Complex programs never run. ∙ Anything worth doing once will probably have to be done twice. The
Functional indeterminancy Theorem: ∙ In complex systems, malfunction and even total nonfunction may not be detectable for long periods, if ever. The
Kantian Hypothesis -or- Know-Nothing Theorem: ∙ Large complex systems are beyond human capacity to evaluate. The Newtonian Lay of Systems-Inertia: ∙ A
system that performs a certain way will continue to operate in that way regardless of the need of of changed conditions. ∙ A system continues to do its
thing, regardless of need. ∙ Systems develop goals of their own the instant they come into being. ∙ Intrasystem goals come first. Failure-Mode Theorems: ∙
Complex systems usually operate in failure mode. ∙ A complex system can fail in a infinite number of ways. ∙ If anything can go wrong, it will. ∙ The mode
of failure of a complex system cannot ordinarily be predicted from its structure. ∙ The crucial variables are discovered by accident. ∙ The larger the
system, the greater the probability of unexpected failure. ∙ "Success" or "function" in any system may be failure in the larger or smaller systems to which
the system is connected. ∙ In setting up a new system, tread softly. You may be disturbing another system that is actually working. The Fail-Safe Theorem:
∙ When a fail-safe system fails, it fails by failing to fail safe. ∙ Complex systems tend to produce complex responses (not solutions) to problems. ∙ Great
advances are not produced by systems designed to produce great advances. ∙ Loose systems last longer and work better. ∙ Efficient systems are dangerous to
themselves and to others. The Vector Theory of Systems: ∙ Systems run better when designed to run downhill. ∙ Systems aligned with human motivational
vectors will sometimes work. Systems opposing such vectors work poorly or not at all. Advanced Systems Theories: ∙ Everything is a system. ∙ Everything is
a part of a larger system. ∙ The universe is infinitely systematized, both upward [larger systems] and downward [smaller systems]. ∙ All systems are
infinitely complex. (The illusion of simplicity comes from focusing attention on one or a few variables.) ∙ Parameters are variables travelling under an
assumed name.
</pre>
Output when specifying: <tt> 76 </tt>
<pre style="height:15ex;overflow:scroll">
────────── Computer programming laws ────────── The Primal Scenario -or-
Basic Datum of Experience: ∙ Systems in general work poorly or not at all.
∙ Nothing complicated works. ∙ Complicated systems seldom exceed 5%
efficiency. ∙ There is always a fly in the ointment. The Fundamental
Theorem: ∙ New systems generate new problems. Occam's Razor: ∙ Systems
should not be unnecessarily multiplied. The Law of Conservation of Energy:
∙ The total amount of energy in the universe is constant. ∙ Systems operate
by redistributing energy into different forms and into accumulations of
different sizes. Laws of Growth: ∙ Systems tend to grow, and as they grow,
they encroach. The Big-Bang Theorem of Systems-Cosmology: ∙ Systems tend to
expand to fill the known universe. Parkinson's Extended Law: ∙ The system
itself tends to expand at 5-6% per annum. The Generalized Uncertainty
Principle: ∙ Systems display antics. ∙ Complicated systems produce
unexpected outcomes. ∙ The total behavior of large systems cannot be
predicted. The Non-Addivity Theorem of Systems-Behavior -or- Climax Design
Theorem: ∙ A large system, produced by expanding the dimensions of a
smaller system, does not behave like the smaller system. LeChateliers's
Principle: ∙ Complex systems tend to oppose their own proper function. ∙
Systems get in the way. ∙ The system always kicks back. ∙ Positive feedback
is dangerous. Functionary's Falsity: ∙ People in systems do not do what the
system says they are doing. ∙ The function performed by a system is not
operationally identical to the function of the same name performed by a
man. ∙ A function performed by a larger system is not operationally
identical to the function of the same name performed by a smaller system.
The Fundamental Law of Administrative Workings: ∙ Things are what they are
reported to be. ∙ The real world is whatever is reported to the system. ∙
If it isn't official; it didn't happen. ∙ If it's made in Detriot, it must
be an automobile. ∙ A system is no better than its sensory organs. ∙ To
those within a system, the outside reality tends to pale and disappear. ∙
Systems attract systems-people. ∙ For every human system, there is a type
of person adapted to thrive on it or in it. ∙ The bigger the system, the
narrower and more specialized the interface with individuals.
Administrator's Anxiety: ∙ Pushing on the systems doesn't help. It just
makes things worse. ∙ A complex system cannot be "made" to work. It either
works or it doesn't. ∙ A simple system, designed from scratch, sometimes
works. ∙ A simple system may or may not work. ∙ Some complex systems
actually work. ∙ If a system is working, leave it alone. ∙ A complex system
that works is invariably found to have evolved from a simple system that
works. ∙ A complex system designed from scratch never works and cannot be
patched up to make it work. You have to start over, beginning with a
working simple system. ∙ Programs never run the first time. ∙ Complex
programs never run. ∙ Anything worth doing once will probably have to be
done twice. The Functional indeterminancy Theorem: ∙ In complex systems,
malfunction and even total nonfunction may not be detectable for long
periods, if ever. The Kantian Hypothesis -or- Know-Nothing Theorem: ∙ Large
complex systems are beyond human capacity to evaluate. The Newtonian Lay of
Systems-Inertia: ∙ A system that performs a certain way will continue to
operate in that way regardless of the need of of changed conditions. ∙ A
system continues to do its thing, regardless of need. ∙ Systems develop
goals of their own the instant they come into being. ∙ Intrasystem goals
come first. Failure-Mode Theorems: ∙ Complex systems usually operate in
failure mode. ∙ A complex system can fail in a infinite number of ways. ∙
If anything can go wrong, it will. ∙ The mode of failure of a complex
system cannot ordinarily be predicted from its structure. ∙ The crucial
variables are discovered by accident. ∙ The larger the system, the greater
the probability of unexpected failure. ∙ "Success" or "function" in any
system may be failure in the larger or smaller systems to which the system
is connected. ∙ In setting up a new system, tread softly. You may be
disturbing another system that is actually working. The Fail-Safe Theorem:
∙ When a fail-safe system fails, it fails by failing to fail safe. ∙
Complex systems tend to produce complex responses (not solutions) to
problems. ∙ Great advances are not produced by systems designed to produce
great advances. ∙ Loose systems last longer and work better. ∙ Efficient
systems are dangerous to themselves and to others. The Vector Theory of
Systems: ∙ Systems run better when designed to run downhill. ∙ Systems
aligned with human motivational vectors will sometimes work. Systems
opposing such vectors work poorly or not at all. Advanced Systems Theories:
∙ Everything is a system. ∙ Everything is a part of a larger system. ∙ The
universe is infinitely systematized, both upward [larger systems] and
downward [smaller systems]. ∙ All systems are infinitely complex. (The
illusion of simplicity comes from focusing attention on one or a few
variables.) ∙ Parameters are variables travelling under an assumed name.
</pre>
Output [justified] when specifying: <tt> -70 </tt>
<pre style="height:15ex;overflow:scroll">
────────── Computer programming laws ────────── The Primal Scenario
-or- Basic Datum of Experience: ∙ Systems in general work poorly or
not at all. ∙ Nothing complicated works. ∙ Complicated systems seldom
exceed 5% efficiency. ∙ There is always a fly in the ointment. The
Fundamental Theorem: ∙ New systems generate new problems. Occam's
Razor: ∙ Systems should not be unnecessarily multiplied. The Law of
Conservation of Energy: ∙ The total amount of energy in the universe
is constant. ∙ Systems operate by redistributing energy into different
forms and into accumulations of different sizes. Laws of Growth: ∙
Systems tend to grow, and as they grow, they encroach. The Big-Bang
Theorem of Systems-Cosmology: ∙ Systems tend to expand to fill the
known universe. Parkinson's Extended Law: ∙ The system itself tends to
expand at 5-6% per annum. The Generalized Uncertainty Principle: ∙
Systems display antics. ∙ Complicated systems produce unexpected
outcomes. ∙ The total behavior of large systems cannot be predicted.
The Non-Addivity Theorem of Systems-Behavior -or- Climax Design
Theorem: ∙ A large system, produced by expanding the dimensions of a
smaller system, does not behave like the smaller system.
LeChateliers's Principle: ∙ Complex systems tend to oppose their own
proper function. ∙ Systems get in the way. ∙ The system always kicks
back. ∙ Positive feedback is dangerous. Functionary's Falsity: ∙
People in systems do not do what the system says they are doing. ∙ The
function performed by a system is not operationally identical to the
function of the same name performed by a man. ∙ A function performed
by a larger system is not operationally identical to the function of
the same name performed by a smaller system. The Fundamental Law of
Administrative Workings: ∙ Things are what they are reported to be. ∙
The real world is whatever is reported to the system. ∙ If it isn't
official; it didn't happen. ∙ If it's made in Detriot, it must be an
automobile. ∙ A system is no better than its sensory organs. ∙ To
those within a system, the outside reality tends to pale and
disappear. ∙ Systems attract systems-people. ∙ For every human system,
there is a type of person adapted to thrive on it or in it. ∙ The
bigger the system, the narrower and more specialized the interface
with individuals. Administrator's Anxiety: ∙ Pushing on the systems
doesn't help. It just makes things worse. ∙ A complex system cannot be
"made" to work. It either works or it doesn't. ∙ A simple system,
designed from scratch, sometimes works. ∙ A simple system may or may
not work. ∙ Some complex systems actually work. ∙ If a system is
working, leave it alone. ∙ A complex system that works is invariably
found to have evolved from a simple system that works. ∙ A complex
system designed from scratch never works and cannot be patched up to
make it work. You have to start over, beginning with a working simple
system. ∙ Programs never run the first time. ∙ Complex programs never
run. ∙ Anything worth doing once will probably have to be done twice.
The Functional indeterminancy Theorem: ∙ In complex systems,
malfunction and even total nonfunction may not be detectable for long
periods, if ever. The Kantian Hypothesis -or- Know-Nothing Theorem: ∙
Large complex systems are beyond human capacity to evaluate. The
Newtonian Lay of Systems-Inertia: ∙ A system that performs a certain
way will continue to operate in that way regardless of the need of of
changed conditions. ∙ A system continues to do its thing, regardless
of need. ∙ Systems develop goals of their own the instant they come
into being. ∙ Intrasystem goals come first. Failure-Mode Theorems: ∙
Complex systems usually operate in failure mode. ∙ A complex system
can fail in a infinite number of ways. ∙ If anything can go wrong, it
will. ∙ The mode of failure of a complex system cannot ordinarily be
predicted from its structure. ∙ The crucial variables are discovered
by accident. ∙ The larger the system, the greater the probability of
unexpected failure. ∙ "Success" or "function" in any system may be
failure in the larger or smaller systems to which the system is
connected. ∙ In setting up a new system, tread softly. You may be
disturbing another system that is actually working. The Fail-Safe
Theorem: ∙ When a fail-safe system fails, it fails by failing to fail
safe. ∙ Complex systems tend to produce complex responses (not
solutions) to problems. ∙ Great advances are not produced by systems
designed to produce great advances. ∙ Loose systems last longer and
work better. ∙ Efficient systems are dangerous to themselves and to
others. The Vector Theory of Systems: ∙ Systems run better when
designed to run downhill. ∙ Systems aligned with human motivational
vectors will sometimes work. Systems opposing such vectors work poorly
or not at all. Advanced Systems Theories: ∙ Everything is a system. ∙
Everything is a part of a larger system. ∙ The universe is infinitely
systematized, both upward [larger systems] and downward [smaller
systems]. ∙ All systems are infinitely complex. (The illusion of
simplicity comes from focusing attention on one or a few variables.) ∙
Parameters are variables travelling under an assumed name.
</pre>
</pre>