Gerardo,
This will work nicely assuming you are writing to a Windows-style text
file. (i.e. a text file where lines are terminated with the CR and LF
characters.)
I won't reiterate what Vern already said, and you've already discovered,
but there are a few extra things that are probably worth noting:
1) When you write data (with the write API) it writes at the spot in the
file where things are currently positioned. When a file is opened, the
file position will default to byte 0 (the start of the file) so when you
write, it'll overwrite from the start. In your case, you are clearing
the file (O_TRUNC does that) so this works nicely.
2) If you wanted to add your data to an existing file, you can add the
O_APPEND flag to your open() call. This will force writes to be at the
end of the file instead of the start.
3) Or, if you want to overwrite existing data _and_ be able to write at
the end in a single open, the lseek() API can be used to set the
position, so you can set it at the start of the file, or the end of the
file, or at any arbitrary byte position in between. If you do that,
write() will write the data at whichever point you set it at.
Please do remember that this is a stream file, not a record-based file.
So the system doesn't know that the file is organized into records.
When you overwrite stuff, you are overwriting a range of bytes in the
file, not a "record." This can make a huge difference if the length of
the record doesn't match the one you're overwriting!
-SK
On 10/15/2014 12:49 PM, Gerardo Alberto Martinez Rosales wrote:
Thx Vern
That is the solution, I was looking
To create a new line in file IFS
The solution is
crlf s 2 inz(x'0d25)
Open ......
Eval data = ('line one' + crlf)
Callp write(.....
Eval data = ('line two' + crlf)
Callp write(......
Callp close(dd)
Thx very much
Again Vern.
Regards.
On Oct 15, 2014 11:25 AM, "Vernon Hamberg" <vhamberg@xxxxxxxxxxxxxxx>
wrote:
Geraldo
As an Amazon Associate we earn from qualifying purchases.