>>-writefile--pathname--mode--stem--+--------+-----------------><
'-append-'
Function
writefile invokes the open, write, and close callable
services to write or append text files, with lines up to 1024 characters
long.
Parameters
- pathname
- A pathname for the file.
- mode
- A three- or four-digit number, corresponding to the access permission
bits. Each digit must be in the range 0–7,
and at least three digits must be specified. For more information
on permissions, see REXX predefined variables.
- stem
- The name of a stem variable that contains the information
to be written to the file. stem.0 is set to the number of
lines to be written. stem.1 through stem.n,
where n is the total number of variables written, each contain
a line to be written. A newline is written to the file following each
line.
Within the stem, you can use the predefined variables beginning
with ESC_ the same way you use C language escape sequences to avoid
code page dependence with some control characters. See the usage notes
for write.
- append
- An optional flag to indicate that the information is to be appended
to the file (the file must already exist), as follows:
- 0
- Do not append. (This is the default value.)
- 1
- Append the information to the file.
Usage notes
File I/O stops when
writefile sets a return code.
writefile can set the following return codes:
- 4
- A line is longer than 1024 characters.
- 8
- A write was attempted but not all of the data could
be written. This situation typically happens when the file system
runs out of space.
For further usage notes, see:
Example
In the following example, assume that
fname and the stem
file. were assigned values earlier in the exec:
"writefile (fname) 600 file."