Products Downloads


French version


 

 

Important: For a given alias, the VaToolBx DLL must have already been loaded (using the LOAD_DLL instruction) when the VaToolBxOpenFile function is called.

 

This function is used to open a text file.

 

Context

  • Windows client,

  • Windows server,

  • Java client,

  • Java server,

  • Adelia Web client,

  • Adelia Cloud client,

  • Event Adelia client.

Note: Encoding management and 'i' mode are not taken into account in mobile generation.

 

Parameters

ALPHA(n)

Alias

Logical name given to the file to be opened.

ALPHA(n) or IMAGE

FileName or Buffer

Access path and name of the (physical) file to be opened,

or

Buffer memory managed using an IMAGE variable.

Note: The IMAGE Buffer parameter is applicable for Java context only.

ALPHA(n)

Mode

File opening mode:

r Read
w Write
a  Add
t Text mode (default mode) is used to open the file. In this mode, carriage return-linefeed character combinations (characters OD-OA) are replaced with the linefeed character (OA) in read mode. The latter is itself replaced with the carriage return-linefeed character combinations in write mode.
The characters are converted according to the specified encoding, or, by default:
    • ANSI for the C/Windows platform.
    • JVM encoding for the Java Patform, ANSI for Windows and UTF-8 for Linux.

If it exists, the text mode must be used with one of the other modes: read (r), write (w) or add (a).
(For example: rt, wt, at.)
b

Open a file in pseudo-binary mode. In this mode, there is no specific management of carriage return-line feed characters. The characters are converted according to the specified encoding, or, by default:

    • ANSI for the C/Windows platform.
    • JVM encoding for the Java Patform, ANSI for Windows and UTF-8 for Linux. 

If it is present, this mode must be used with one of the read (r), write (w) or add (a) modes.

(e.g. rb, wb, ab.)

i

Open a file in strict binary mode. In this mode, no character conversion is carried out. The bytes are read or written without any conversion: specifying encoding returns a 14 error.

If it is present, this mode must be used with one of the read (r), write (w) or add (a) modes.(e.g. ri, wi, ai.)

 


Note: Modes t, b and i are exclusive.


,enc=UNICODE

,enc=ANSI,enc=ASCII

,enc=UTF-8

,enc=UTF-8-NO-BOM

,enc=UTF-16LE

,enc=UTF-16LE-NO-BOM

,enc=UTF-16BE

,enc=UTF-16BE-NO-BOM

,enc=UTF-32LE

,enc=UTF-32LE-NO-BOM

,enc=UTF-32BE

,enc=UTF-32BE-NO-BOM


Used to specify the character encoding to use for text mode (t) or pseudo-binary mode (b).
 


Note: When the encoding is explicitly specified, in read or add, the encoding used is that of the file BOM as a priority if it exists.

In write mode or when adding to an empty file, UTF-8, UTF-16LE, UTF-16BE, UTF-32LE and UTF-32BE encoding systematically add a BOM to the file. The same encoding name with "–NO-BOM" added needs to be used to obtain a file without BOM.

By default, the encoding is ANSI.

In the absence of BOM or in write mode, the UNICODE encoding is equivalent to the UTF-16BE encoding.

 

NUM_BIN_4

CodeRetour

Return code for the operation:

0    The operation was carried out correctly.

2    Alias already used.

3    The file could not be opened.

7    Memory problem.

9    Character converter initialisation problem.

10  Error when writing the BOM.

13  Invalid opening mode.

14  Encoding not compatible with opening mode.

15  Encoding not recognised/supported.

 

Examples

Example 1:

Alias = 'TextFile'

FileName = 'C:\CONFIG\USER.TXT'

Mode = 'w'

CALL_DLL 'VATOOLBX.DLL' 'VaToolBxOpenFile' Alias FileName Mode ReturnCode

 

Example 2 (Java context only):

IMAGE Buffer

 

Alias = 'idInf1'

Mode = 'w'

CALL_DLL 'VATOOLBX.DLL' 'VaToolBxOpenFile' Alias Buffer Mode ReturnCoder

 

ExAmple 3 :

Alias = 'UTF8_TextFile'

FileName = 'C:\CONFIG\USER.TXT'

Mode = 'w,enc=UTF-8'

CALL_DLL 'VATOOLBX.DLL' 'VaToolBxOpenFile' Alias FileName Mode ReturnCode

 

List of the VaToolBx functions by topic

 

↑ Top of page

  • Aucune étiquette