File Open

FileOpen keeps a file open to speed up a large number of write operations.

This function creates a FileHandle object in its execution path that can be used by the TextFileWrite or BinaryFileWrite functions to write to the opened file.

You can also use the SetValue function to assign values to the FileHandle's 'Append' property to add content that way. See the Examples below.

Properties

File Path

The full path to the file that has to be kept open for writing.

Is Text

Indicates if the file to open (or create) is a text file.

Codepage

Only displayed if the Is Text property option is checked.

Selects the character encoding to use when writing text to the file.

The default Codepage is the one used in your operating system.

File Does Not Exist

You can opt to create the file or return an error if the file already exists.

File Exists

Only displayed if the Is Text property option is checked.

Specifies what to do if the file already exists.

Options:

  • Append Data: Any text that is written to the file is added to the end of the file.

  • Increment File Name: Adds a number to the file name to make it unique, starting with 1.

  • Overwrite File: Replaces all content in the file with the new content.

  • Throw Exception: Stops the function's processing and returns an error.


Examples

Suppose you have a long list of lines of text to write to a file. Using the FileOpen function, as shown below, will run much quicker than doing it without the FileOpen function.

Use with TextFileWrite

Set the 'File path' property of the TextFileWrite function to FileOpen.File.FileHandle.

TextFileWrite

Use with SetValue

Set the 'Target' property of the SetValue function to FileOpen.File.FileHandle.Append or FileOpen.File.FileHandle.AppendLine. 'AppendLine' will add a line terminator after the text.

SetValue Example


Last updated