open("file_path")

The open() function opens a file for reading and writing operations, making it the currently active file for subsequent file operations. It also returns the file's contents.

Syntax

open("file_path")

Parameters

  • file_path - The path to the file to open. This can be:

    • A relative path from the current directory

    • An absolute path

    • A UUID reference to a file

Return Value

The contents of the opened file as a string.

Description

The open() function serves two purposes:

  1. It makes the specified file the "currently open file" for subsequent file operations like fileGet() and fileSet()

  2. It returns the entire contents of the file as a string

This function requires appropriate file permissions to be granted to the application.

Examples

Basic File Opening

Opening and Processing a File

Using File UUID

Error Handling

Notes

  • The file remains open until another file is opened or the application closes

  • Only one file can be open at a time

  • If the file doesn't exist, an error will be thrown

  • The function requires appropriate file permissions

  • For large files, be aware of memory usage when loading the entire file content

  • The returned content is always a string; use parsing functions like JsonParse() for structured data

Last updated

Was this helpful?