If the 3rd line consists of less number of characters than the overlaid data then a new line is being added. If the overlaid data is having more number of characters than the 3rd line then the remaining characters are overwritten to the next line.
Suppose in the third line has “Third line”, and when the above program is executed then the 3rd line is divided to ‘linedata’ and new line ‘ne’ was inserted.
Original File:
First Line
Second Line
Third Line
Fourth Line
Fifth Line
After Execution:
First Line
Second Line
linedata
ne
Fourth Line
Fifth Line
If the 3rd line is overlaid with ‘Refreshed-data’ then ‘data’ was overwritten on 4th line.
First Line
Second Line
Refreshed-
datath Line
Fifth Line
Could somebody suggest me how to overcome this?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I am using Regina REXX on AIX environment. I have a file with 5 lines and I want to read the 3rd line and replace with new data.
OPTIONS NOLINEOUTTRUNC
Lineinfo = LINEIN(finename, 3)
Lineinfo = OVERLAY(‘linedata’, Lineinfo)
X = LINEOUT(filename, lineinfo, 3)
If the 3rd line consists of less number of characters than the overlaid data then a new line is being added. If the overlaid data is having more number of characters than the 3rd line then the remaining characters are overwritten to the next line.
Suppose in the third line has “Third line”, and when the above program is executed then the 3rd line is divided to ‘linedata’ and new line ‘ne’ was inserted.
Original File:
First Line
Second Line
Third Line
Fourth Line
Fifth Line
After Execution:
First Line
Second Line
linedata
ne
Fourth Line
Fifth Line
If the 3rd line is overlaid with ‘Refreshed-data’ then ‘data’ was overwritten on 4th line.
First Line
Second Line
Refreshed-
datath Line
Fifth Line
Could somebody suggest me how to overcome this?
OPTIONS NOLINEOUTTRUNC
Lineinfo = LINEIN(finename, 3)
**X = CLOSE(filename)**
Lineinfo = OVERLAY(‘linedata’, Lineinfo)
X = LINEOUT(filename, lineinfo, 3)