Skip to main content

MF:  I have a program that reads a file in sequential order.  I do not want to make extensive changes to the existing programs .  it possible to do a rewrite of a record twice in a row (Read Rewrite, Rewrite) ?  If not, how would make it possible ?

MF:  I have a program that reads a file in sequential order.  I do not want to make extensive changes to the existing programs .  it possible to do a rewrite of a record twice in a row (Read Rewrite, Rewrite) ?  If not, how would make it possible ?

I am assuming that you are referring to reading an Indexed file sequentially, is that correct?

A rewrite on an indexed file does not change the current record position pointer so that will still point to the record that you just updated.

This should not be a problem to do back to back rewrites but why would you want to do such a thing?

Thanks.


MF:  I have a program that reads a file in sequential order.  I do not want to make extensive changes to the existing programs .  it possible to do a rewrite of a record twice in a row (Read Rewrite, Rewrite) ?  If not, how would make it possible ?

No, it is just a simple flat non-indexed file.  And I would not want to do such a thing, but it was already written by someone else and I need to fix the potential problem.


MF:  I have a program that reads a file in sequential order.  I do not want to make extensive changes to the existing programs .  it possible to do a rewrite of a record twice in a row (Read Rewrite, Rewrite) ?  If not, how would make it possible ?

This will not work for a sequential file.

On the second rewrite you will get a file status 43.

43 Files in sequential access mode. The last I/O statement executed for the file, before the execution of a DELETE or REWRITE statement, was not a READ statement.


MF:  I have a program that reads a file in sequential order.  I do not want to make extensive changes to the existing programs .  it possible to do a rewrite of a record twice in a row (Read Rewrite, Rewrite) ?  If not, how would make it possible ?

Which is exactly what I got.  Now the object is how to fix it without a partial rewrite of the logic.  I was thinking of a read previous but I believe that only works on relative files.  Any other ideas ?


MF:  I have a program that reads a file in sequential order.  I do not want to make extensive changes to the existing programs .  it possible to do a rewrite of a record twice in a row (Read Rewrite, Rewrite) ?  If not, how would make it possible ?

Yes, read previous is only supported for indexed and relative files.

What would be the problem if you just commented out the first rewrite statement as the second one will overwrite what is written in the first rewrite anyway?


MF:  I have a program that reads a file in sequential order.  I do not want to make extensive changes to the existing programs .  it possible to do a rewrite of a record twice in a row (Read Rewrite, Rewrite) ?  If not, how would make it possible ?

The issue is that it is rewriting the data field by field as it changes or not changes while other may still have access to the data.


MF:  I have a program that reads a file in sequential order.  I do not want to make extensive changes to the existing programs .  it possible to do a rewrite of a record twice in a row (Read Rewrite, Rewrite) ?  If not, how would make it possible ?

The issue is that it is rewriting the data field by field as it changes or not changes while other may still have access to the data.


MF:  I have a program that reads a file in sequential order.  I do not want to make extensive changes to the existing programs .  it possible to do a rewrite of a record twice in a row (Read Rewrite, Rewrite) ?  If not, how would make it possible ?

The issue is that it is rewriting the data field by field as it changes or not changes while other may still have access to the data.