TextFile_Open()

Examples


The TextFile_Open() function opens a specified text file.

Syntax

TextFile_Open(pathname, mode, access)

Parameters

pathname A string containing the complete generic pathname to the text file, including the name of the file. If the file specified by pathname doesn’t exist, it will be created.

mode An integer corresponding to one of the following file open modes:

[spacer]

Value

Description

0

The file will be opened at the beginning of the text file, allowing you to overwrite or read existing text.

1

The file will be opened at the end of the text file, allowing you to append new text to the file.


access – An integer that sets the following access rights to the file:

[spacer]

Value

Description

0

Allows write exclusive access.

1

Allows read-only shared access.

2

Allows write shared access.


Return value

An integer returned from the operating system that’s used to uniquely identify this file. This value is used with the TextFile_Close(), TextFile_ReadLine(), TextFile_ReadText(), TextFile_WriteDOS(), TextFile_WriteLine() and TextFile_WriteText() functions.

Comments

When you open a text file at the beginning (where the mode parameter is set to 0), with write access (where the access parameter is set to either 0 or 2) any text currently in the file will be deleted in preparation for writing new data. To avoid deleting existing data, open a text file at the end of the file (using a mode of 1) when using write access.

After you open a text file, the insertion point is determined by the mode parameter. The following illustration shows a text file and the insertion points that can be determined by mode:

[spacer]

If you open a text file at its beginning, use TextFile_ReadLine() to read a line in the file, and return it to a text field in your application. If you open a text file at the end of the file, use TextFile_WriteLine() to write text from your application to the file.


Documentation Feedback