Important: For a given alias, the VaToolBx DLL must have already been loaded (using the LOAD_DLL instruction) when the VaToolBxOpenFile function is called, and must still be loaded when the VaToolBxWriteString function is called.
This function is used to write a formatted character string in a text file. The text will be inserted at the current position in the file. This function adds a carriage return after the string.
Context
Windows client,
Windows server,
Mobile client,
Mobile server,
Java client,
Java server,
Adelia Web client,
Adelia Cloud client.
Note: Encoding management and 'i' mode are not taken into account in mobile generation.
Parameters
ALPHA(n) |
Alias |
File name. |
ALPHA(n) |
Buffer |
Text to be written by the function. |
NUM_BIN_4 |
ReturnCode |
Return code for the operation: 0 Operation completed successfully. 2 Alias not defined. 5 Problem with write operation. 11 Error when converting characters. 12 Strict binary mode is not supported. 13 Invalid opening mode. |
Notes:
By default ('t' or 'b' mode), if no encoding is specified in the file opening mode, the text is encoded in ANSI even if the host program is generated in UNICODE.
In 't' mode, the line feed character is always replaced by the carriage return-line feed sequence.
ANSI generation 0A -> 0D-0A (if destEnc=ANSI or UTF-8); 0D-00-0A-00 (if destEnc=UTF-16LE); 00-0D-00-0A (if destEnc=UTF-16BE…)
Unicode generation (C) 0A-00 -> 0D-0A (if destEnc=ANSI or UTF-8); 0D-00-0A-00 (if destEnc=UTF-16LE); 00-0D-00-0A (if destEnc=UTF-16BE…).
The carriage return added at the end of the string is encoded according to the encoding chosen in the opening mode (ANSI by default => addition of a carriage return-line feed: 0D-0A; with UTF-16LE encoding we would have: 0D-00-0A-00).
Strict binary mode ('i') is not supported by the function.
Example
Alias = 'TextFile'
Buffer = 'Text To Add'
CALL_DLL 'VATOOLBX.DLL' 'VaToolBxWriteString' Alias Buffer ReturnCode
List of the VaToolBx functions by topic