View previous topic :: View next topic
|
Author |
Message |
surya anem
New User
Joined: 20 Dec 2007 Posts: 54 Location: Hyderabad
|
|
|
|
I'm working on a tool which reads the data from the file and if data is edited then it is written back into the file...
I'm using the following code:
Code: |
DO I = 1 TO DATAL.0
IF I = CURR THEN
DO
DATAS.CURR = DATAL.CURR
DO S = 1 TO COUNT
DATAS.CURR = OVERLAY(DATA.S,DATAS.CURR,PN.S,LEN.S,' ')
END
"EXECIO * DISKRU DATAREAD (FINIS STEM DATAS."
LEAVE
END
"EXECIO * DISKR DATAREAD (FINIS STEM DATAS."
END
|
In the above code...datal.0 contains the total number of lines in the file and curr is the edited line number.....
the above code is working well if the line number is other than 1 .if the line number is 1 then it is writing the data and erasing all the other line...
kindly suggest to me on how to overcome the problem
regards,
surya |
|
Back to top |
|
|
surya anem
New User
Joined: 20 Dec 2007 Posts: 54 Location: Hyderabad
|
|
|
|
I also tried the same code with
DISKW instead of DISKRU but the same problem exists |
|
Back to top |
|
|
karthikraman_m
New User
Joined: 10 Jun 2005 Posts: 12 Location: India
|
|
|
|
Hi Surya,
When I=1, this will be the first itieration and the below statement
"EXECIO * DISKR DATAREAD (FINIS STEM DATAS."
has never been executed and so the DATAS is empty.
Then the statement
DATAS.CURR = DATAL.CURR
copies only the first line to DATAS, which is then written into the output. So, further reads to the DATAREAD reads only the first line.
To solve this issue, move the line
"EXECIO * DISKR DATAREAD (FINIS STEM DATAS."
before
IF I = CURR THEN
My suggestion is - Performing I/O inside a loop is not good performance wise. You may want to read and write only once and perform the required tasks using a different logic.
Thanks,
Karthik Raman |
|
Back to top |
|
|
|