File Access Modes
The CFile class can access files in binary or text compatibility mode for reading, writing, or appending. The Open method sets the file access using an access mode string that describes all of these options. The table below lists pre-defined file access mode strings, which are the standard names inherited from the C language.
File Access Modes
Mode String |
Mode |
"b" |
Open in binary mode. This mode is normally used for data. |
"t" |
Open as text. This mode is used for reading text files. |
"r" |
Open for reading. If the file does not exist, CFile:Open fails. |
"w" |
Open an empty file for writing. If the file exists, it is truncated to zero length. |
"a" |
Open for appending. The file is created if it does not exist. |
"r+" |
Open for reading and writing. If the file does not exist, CFile:Open fails. |
"w+" |
Open an empty file for reading and writing. If the file does not exist, it is created. If it exists, its contents are destroyed. |
"a+b" |
Read, Append, or Create in binary mode. |
"a+t" |
Read, Append, or Create in text mode. |
The following script opens a text file for reading and writing, beginning at the end of the file:
|
-- create a new CFile instance |
|
-- open as text for reading and writing |
Mira Pro x64 Script User's Guide, v.8.77 Copyright Ⓒ 2024
Mirametrics, Inc. All Rights Reserved.