File input/output: Difference between revisions

m
→‎version 1: added/changed comments and whitespace, added a comment in the REXX section header, elided the use of a temporary REXX variable (placeholder). .
m (→‎version 1: added/changed comments and whitespace, added a comment in the REXX section header, elided the use of a temporary REXX variable (placeholder). .)
Line 2,336:
 
===version 1===
The two   ''optional''   REXX statements are only needed if there is another REXX program in the invocation chain
<lang rexx>/*REXX program to read a file and store the contents into an output file*/
iFID<br>(which =may 'input.txt'have invoked this program) &nbsp; that already has /*nameone of the input file.and/or output files */open.
oFID<lang =rexx>/*REXX 'output.txt'program reads a file and copies the contents into /*name of thean output file. (on a line by line basis).*/
calliFID = 'input.txt' lineout oFID,,1 /*insurethe outputname startsof atthe line 1input file. */
oFID = 'output.txt' /*the name of the output file. */
call lineout iFID,,1 /*insure the input starts at line one.*/ /* ◄■■■■■■ optional. */
call lineout oFID,,1 /*insure the output starts at line one.*/ /* ◄■■■■■■ optional. */
 
do while lines(iFID) \== 0 /*read records until finished.from input 'til finished*/
ycall =lineout oFID, linein(iFID) /*write a (just) /*read a record fromto inputoutput. */
callend /*while*/ lineout oFID,y /*writestick a recordfork in toit, output. we're all done. */</lang>
end /*while ···*/
/*stick a fork in it, we're done.*/</lang>
 
===version 2===