CFile 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.

CFile Access Mode Definitions

Mode String

Translation Mode

Open for:

"rt"

Text

Reading

"wt"

Text

Writing

"w+t"

Text

Write with Append

"r+t"

Text

Read and Write

"a+t"

Text

Read and Write with Append

Example

The following script opens a text file for reading and writing, beginning at the end of the file. Note that the mode name is prefixed by the instance of the class, F, and not by the class name:

F = new_file()

-- create a new CFile instance

F:Open( sPath, "r+t" )

-- open as text for reading and writing

Related Topics

CFile Class, Open. FileOpen


Mira Pro x64 Script User's Guide, Copyright Ⓒ 2023 Mirametrics, Inc. All Rights Reserved.