File input/output: Difference between revisions

Content added Content deleted
(→‎{{header|REXX}}: deleted version 2 as it did not read the record into a variable (as per task requirement).)
m (→‎version 1: utilized better use of lower/uppercase names, added a comment.)
Line 2,103: Line 2,103:
===version 1===
===version 1===
<lang rexx>/*REXX program to read a file and store the contents into an output file*/
<lang rexx>/*REXX program to read a file and store the contents into an output file*/
ifid = 'input.txt' /*name of the input file. */
iFID = 'input.txt' /*name of the input file. */
ofid = 'output.txt' /*name of the output file. */
oFID = 'output.txt' /*name of the output file. */
call lineout ofid,,1 /*insure output starts at line 1.*/
call lineout oFID,,1 /*insure output starts at line 1.*/


do while lines(ifid)\==0 /*read until finished. */
do while lines(iFID)\==0 /*read records until finished. */
y = linein(ifid) /*read a record into a REXX var. */
y = linein(iFID) /*read a record from input. */
call lineout ofid,y /*write a record to output.nt. */
call lineout oFID,y /*write a record to output. */
end
end /*while ···*/
/*stick a fork in it, we're done.*/</lang>
/*stick a fork in it, we're done.*/</lang>

===version 2===
===version 2===
Note that this version is limited to files less than one million bytes (and/or possibly virtual memory).
Note that this version is limited to files less than one million bytes (and/or possibly virtual memory).