View previous topic :: View next topic
|
Author |
Message |
seenivasakan Currently Banned New User
Joined: 13 May 2007 Posts: 13 Location: Karnataka
|
|
|
|
Hi,
I am trying to do a tool to search for a old value and to replace with new value.
i am reading from one file ,once i face the old value i am changing that to new value. See the code snippet as follows:
EX:
Code: |
"Alloc da(filename) f(outdd) shr"
"execio * diskr outdd (finis stem recdd."
Do i=0 to recdd.0
if (pos(str2find,recdd.i) > 0) then
do
LINE_NUM = i
x=pos(str2find,recdd.i)
OLD_DATA=delstr(recdd.i,x,8)
DATA=insert(new_sting,OLD_DATA,x,8)
end
else nop
|
Now i have the updated DATA. i want to write the variable DATA into the line LINE_NUM.
Anyone know how to call EXECIO with line number to be written
Please help me to sort out this issue.
Regards |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
You could open the file for update in the REXX and then just replace the record in situ. Or write to a new file as output.
Or use an ISPF edit macro. Personally I would choose the one file in one file out method. That way you retain the integrity of the original data. |
|
Back to top |
|
|
superk
Global Moderator
Joined: 26 Apr 2004 Posts: 4652 Location: Raleigh, NC, USA
|
|
|
|
I don't get it.
You're reading the entire DD into a stem variable (recdd.). All you need to do is to loop through the stem variables until you meet your criteria for the change. Change the value of that particular stem variable (recdd.i). Leave the loop. Then, just write the DD from the stem variable:
Code: |
"execio * diskw outdd (finis stem recdd."
|
Essentially, you'll just re-write the contents of the entire DD. With the SHR disposition, that shouldn't cause any problems. |
|
Back to top |
|
|
seenivasakan Currently Banned New User
Joined: 13 May 2007 Posts: 13 Location: Karnataka
|
|
|
|
Thanks Expat and Superk
I just re written once i finished the Change.
Now the code works fine.
Thanks again
Regards |
|
Back to top |
|
|
|