Reverse the order of lines in a text file while preserving the contents of each line: Difference between revisions

Content added Content deleted
(Added XPL0 example.)
Line 268: Line 268:
saying 'Nice Doggy'
saying 'Nice Doggy'
"Diplomacy is the art of
"Diplomacy is the art of
</pre>

=={{header|XPL0}}==
Usage: rev <will.txt
<lang XPL0>char Array(1000, 1000); \(tacky)
int Line, Char, I;
def LF=$0A, EOF=$1A;
[Line:= 0;
repeat I:= 0;
repeat Char:= ChIn(1);
Array(Line, I):= Char; I:= I+1;
until Char = LF or Char = EOF;
Line:= Line+1;
until Char = EOF;
for Line:= Line-2 downto 0 do
[I:= 0;
repeat Char:= Array(Line, I); I:= I+1;
ChOut(0, Char);
until Char = LF;
];
]</lang>

{{out}}
<pre>
--- Will Rodgers

until you can find a rock."
saying 'Nice Doggy'
"Diplomacy is the art of

</pre>
</pre>