Example 14.4. FILECOPY program
/* FILECOPY.CMD */ /* This routine copies, as lines, the stream or */ /* file that the first argument names to the stream */ /* or file the second argument names. It is assumed */ /* that the name is not an object, as it could be */ /* if it is passed from another Rexx program. */ parse arg inputname, outputname inputobject = .stream~new(inputname) outputobject = .stream~new(outputname) signal on notready do forever outputobject~lineout(inputobject~linein) end exit notready: return
Example 14.5. COLLECT program
/* COLLECT.CMD */ /* This routine collects characters from the stream */ /* the first argument names until a line is */ /* complete, and then places the line on the */ /* external data queue. */ /* The second argument is a single character that */ /* identifies the end of a line. */ parse arg inputname, lineendchar inputobject = .stream~new(inputname) buffer="" /* zero-length character accumulator */ do forever nextchar=inputobject~charin if nextchar=lineendchar then leave buffer=buffer||nextchar /* add to buffer */ end queue buffer /* place it on the external data queue */
BUFFER
. When the line is complete (for example, when the user presses the Enter key) the loop ends and the language processor places the contents of BUFFER
on the external data queue. The program then ends.