Legato
Legato

GoFiler Legato Script Reference

 

Legato v 1.4j

Application v 5.22b

  

 

Chapter SixFile Functions (continued)

WriteLine Function

Overview

The WriteLine function writes a line of text to a Basic File Object at the current position.

Syntax/Parameters

Syntax

int = WriteLine ( handle hBasicFile, string line, [parameters ... ] );

int = WriteLine ( handle hBasicFile, wstring line, [parameters ... ] );

Parameters

hBasicFile

A handle to a Basic File Object.

line

A string or wstring to write. If additional parameters are present, line is considered a formatted string. See Section 5.2 String Functions for more information on formatted strings.

parameters

Zero or more parameters to be formatted and inserted into line. If no parameters are supplied, line is simply passed through to the result string.

Return Value

Returns an int as ERROR_NONE or a formatted error code on failure. If hBasicFile is invalid, the function will return ERROR_INVALID_HANDLE. Use the GetLastError function to retrieve error information. The GetLastErrorMessage function may contain information to supplement the error code.

Remarks

The WriteLine function permits the usage of a formatted string to write information to the file. Formatted strings allow numeric and other data to be formatted into a string. The format of the string and the data to be inserted depend upon the structure of the line parameter and the contents of the additional parameters passed to the function. For more information on formatted strings, see Section 5.2 String Functions.

Each write operation will have a return and newline added (CR/LR or 0x0D/0x0A).

Note that when a wstring data is used as the line parameter, data written to the file will be in Unicode little endian format. Two considerations are important: (1) that the content of the resulting file is word (16-bit) aligned; and, (2) that the file have a Unicode header. Depending on the application, these considerations may not be important but if the file is to be treated like a Unicode text file they must be followed. If only the WriteLine function is used to write the file, alignment will not be an issue. To write a Unicode header, use the WriteBlock function and add the 16-bit character 0xFEFF before writing text to the file. For example:

wchar   uh;

uh = 0xFEFF;

WriteBlock(hFile, uh);

Note that the literal 0xFEFF cannot be written since its native size is 64-bits.

Related Functions

Platform Support

Go13, Go16, GoFiler Complete, GoFiler Corporate, GoFiler, GoFiler Lite, GoXBRL

Legato IDE, Legato Basic