On Thu, 16 Oct 2008 06:22:27 -0500, P.Sabarish Kannan
<[EMAIL PROTECTED]> wrote:

> I have a requirement to insert some records in the beginning of a file where
>already some lines are existing . i tried using DISKW using MOD , but they are
>appending to the end. How do we insert in the beginning? I am using REXX for
>this program.

As far as I know you can not insert records into an existing file using
EXECIO.  You can append to the end, as you noticed.

I would write the new records into a new file and then copy the existing
file and append its records to that new file.   After that, the exec could
then delete the existing file and rename the new one to the old name if needed.

There is an unsafe alternative: you could read all of the existing data into
REXX variables, then write the new records to the beginning of the existing
file, and then write the data from the variables after that new data. 
However, if an error occurs before you finish the writing then you will have
lost the data in your file.

-- 
  Walt Farrell

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [EMAIL PROTECTED] with the message: GET IBM-MAIN INFO
Search the archives at http://bama.ua.edu/archives/ibm-main.html

Reply via email to