Anonymous user
Stream merge: Difference between revisions
→version 2: changed program so that it can run under PC/REXX and Personal REXX, also insured that running a 2nd time doesn't corrupt the output file.
m (→version 2: added text to the output section header comment about the name of the output file is different than version 1.) |
(→version 2: changed program so that it can run under PC/REXX and Personal REXX, also insured that running a 2nd time doesn't corrupt the output file.) |
||
Line 1,897:
This REXX version reads (in numerical order) ''any'' number of input files in the form of: <big> nnn.TXT </big>
<br>and stops reading subsequent ''new'' input files when it encounters an input file that doesn't exist (or is empty).
This REXX program will execute correctly when executed multiple times.
The input files would/should be named: '''1.TXT 2.TXT 3.TXT 4.TXT ···'''
Line 1,902 ⟶ 1,904:
No ''heap'' is needed to keep track of which record was written, nor needs replenishing from its input file.
<lang rexx>/*REXX pgm reads sorted files (1.TXT, 2.TXT, ···), and writes sorted data ───► ALL.TXT */
@.=copies('ff'x,
do n=1 until @.n==@.;
n=n-1 /*
do forever;
end
if #==0 then exit /*stick a fork in it, we're all done. */
call lineout 'ALL.TXT', @.#;
call rdr # /*
end /*forever*/ /*keep reading/merging until exhausted.*/
/*──────────────────────────────────────────────────────────────────────────────────────*/
rdr:
{{out|output|text= is the same as the 1<sup>st</sup> REXX version when using identical input files, except the output file is named '''ALL.TXT'''}} <br><br>
|