file(fn:cs)

Description:

Open a file with the specified name.

Syntax:

file( fn{:cs})

Note:

The function opens a file named fn.

Parameter:

fn

Name of the file to load. Both the absolute path and the relative path are acceptable. If using the relative path, then it is relative to the main path, which is the one configured on the option menu of esProc, and which by default is the current directory (the directory holding the script file)

If using the relative path, follow these rules:

1. The relative path is relative to the main directory if the latter exists; and the latter is the main directory configured in esProc option menu; search the path where the application is located (for instance, the application directory in IDE is [installation root directory]/esProc/bin);

2. When the main directory is absent and the current script file is already saved, take the directory containing the script file as the main directory;

3. When the main directory is absent and the current script file isn’t saved, search the path where the application is located (for instance, the application directory in IDE is [installation root directory]/esProc/bin)

cs

Character set, which supports jvm's built-in character set and which by default is the default value set by OS

Option:

@s

Search the file names on the non-absolute paths in a specified order: Class path -> Search path-> Main path. The search path is the one configured on the option menu of esProc, and the default main path is the current directory. With this option, the function returns the name of a read-only file

@t

Generate a temporary file under the directory of fn file. Without the fn file, create the temporary file through the Temporary directory, one of esProc options under the Tool menu. When the relative path is used to point to the temporary directory, it is relative to the configured main directory 

@a

Make the write action wait when sharing violation happens

@i

Import file into the memory and generate a file object; the in-memory file is read-only

Return value:

File object

Example:

file("D:/Area.txt":"UTF-8")

Load the Area.txt file from the directory "D:\"; character set is UTF-8.

file("Area.txt")

Load the Area.txt file under the main path.

file@s("data/ Area.txt")

Search the class path first; if not found, then search throughout the list of search paths; lastly, search the main path if not found in the search paths.

file@t("data/Area.txt")

Create a temporary file under the directory data/.

file@i("Area.txt")

Generate an in-memory read-only file object.

file("../demo/zh/txt/Suitor.txt")

As the main directory isn’t configured, search [installation directory]/esProc/demo/zh/txt/ for Suitor.txt.