Quantcast
Channel: Intel® Fortran Compiler
Viewing all articles
Browse latest Browse all 3270

Deleting records from a sequential formatted file

$
0
0

My program creates a file of type sequential formatted that look similar to this:

$KEYWORD
word1
word2
:
wordlast
$END
$COMMENTS
This is a free-form section containing text of
various user comments
$END

The file is then closed. In a subsequent run of the same program, it needs to open this file and edit it  to delete the keyword list with a new list, which can be either longer or shorter than the existing list. How can I do this?

My strategy was to open the file, read records until '$KEYWORD' is found, then delete records until '$END' is found, then backspace, then write the new keyword list. Then I realized I don't know how to delete records in this kind of file! Is it even possible? Does it involve some trick like opening it as a binary or stream-access type?


Viewing all articles
Browse latest Browse all 3270

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>