Openi

Use Openi to open and close a sequential file in read-only mode on one of the available servers from a Sage X3 application server.

Syntax

 OpeniOpeni Using [ABBREVIATION]Openi FILE_EXPROpeni FILE_EXPR Using [ABBREVIATION]Openi FILE_EXPR, SEEK_EXPROpeni FILE_EXPR, SEEK_EXPR Using [ABBREVIATION]
* `FILE_EXPR` is an expression that returns a string containing the path of the file to open.* `SEEK_EXPR` is an integer expression that returns the offset in the file (in bytes) from which the read starts. If omitted or if 0, the read starts from the beginning.* `ABBREVIATION` is an abbreviation that identifies the channel opened to read the file.

Examples

 # Let's open a file on the server, skipping the first 10 charactersOpeni "C:\Temp\my_file.txt",10...# Close the last file opened to readOpeni# Opening a file on the "distrib" serverOpeni "distrib@"+[L]NOMFIC# Open two files located in the TMP sub-directory of the folder directory on the application serverOpeni filpath('TMP','rdfile1','') Using [YYY]Openi filpath('TMP','rdfile2','') Using [ZZZ]# Close the two previously opened filesOpeni Using [YYY]Openi Using [ZZZ]

Description and comments

Use Openi to open a file for reading data with Rdseq and Getseq.

The first parameter is the file path that must be opened:

The value given in the 2nd parameter is used to position the read position (in bytes) in the file:

When a unique file is opened, there is no need to give an abbreviation. If several files are opened, it is preferable to use an abbreviation that can be freely chosen and used later to identify the channel used.
* The maximum number of sequential files that can be opened simultaneously is given by the value of the adxmso system variable.
* For a given abbreviation (or without abbreviation), only one sequential file can be opened by Openi or Openio at a given moment. Opening a file in write mode closes any file that may have been previously opened with Openi or Openio with this abbreviation (or with no abbreviation).

The current read position can be known:
* By adxseek(0) if the file has been opened without abbreviation.
* By adxseek("ABREV") if the [ABREV] abbreviation is used.

Execution restriction in Clouds environment

For obvious security reasons, the execution of this instruction is controlled on Clouds environments:

If the conditions defined by the sandbox are not fulfilled, an error 27 will be raised.

For more information, look at the sandbox configuration page.

Associated errors

Error codeDescription
10FILE_EXPR is not a Char type or SEEK_EXPR is not numeric.
20Nonexistent file or path folder.
25System error when connecting to a remote server.
27Access not possible, permission denied.
50exp_depl < 0.
57No seek operation allowed on the file.
60Too many channels used.

See also

Openo, Openio, Seek, Getseq, Rdseq, Putseq, Wrseq, adxifs, adxirs, adxium, adxmso, adxseek.