Was this helpful?
File Modes
A file can be opened in one of four modes. The mode determines where the file is positioned when opened, and what functions are allowed. After you close a file, you can reopen the file in a different mode, depending on what you are doing. For example, you can create a file in create mode. You can close the file and later reopen it in append mode to add more data. The mode can be:
read
Opens a file for reading of data. Read mode opens a file to the beginning. You cannot write to a file opened in read mode. You can reposition a binary or stream file in read mode.
update
Allows both reading and writing of data. Update mode opens a file to the beginning. You can reposition a binary or stream file in update mode. You can update a record by repositioning the file to the beginning of the record, then writing the new data.
create
Opens the specified file and positions it to the beginning. If a file by that name does not exist, the openfile() statement creates the file. If a file by that name exists, it overwrites the existing file.
To create a new file, open the file in create mode.
You cannot read, position or rewind a file opened with create mode.
append
Allows writing data to the end of a file. You cannot read, position or rewind a file opened with append mode.
Last modified date: 08/14/2024