WriteLine

InstallShield 2016 » InstallScript Language Reference

The WriteLine function writes a line of text to a text file opened in append mode. You must first set the file mode to append mode with OpenFileMode, and then either create the file with CreateFile, or open the file with OpenFile, before calling WriteLine. This function places the line at the end of the file.

WriteLine produces lines that have a carriage return and line feed character at the end of the line. To write to a binary file, use WriteBytes.

Caution • This function does not work with files opened in read-only mode.

Syntax

WriteLine ( nvFileHandle, szLine );

Parameters

WriteLine Parameters

Parameter

Description

nvFileHandle

Specifies the file handle of an open file. The handle is obtained from OpenFile or CreateFile.

szLine

Specifies a string that contains the text to write to the file.

Note • You can embed double quotation marks inside a string by delimiting the string with single quotation marks. For example, if you want to write the string "This string contains a double "quotation mark."", you can use the following code:

WriteLine(nvFileHandle, 'This string contains a double "quotation mark."');

Caution • Do not attempt to write multiple lines by embedding newline characters in the string you pass in szLine. The following code writes the string as one line, with an unprintable character between "one" and "This":

    szString = "This is line one\nThis is two";    WriteLine(nvFileHandle, szString);

To write two lines with one call to WriteLine, you must embed a return and a newline (in that order):

    szString = "This is line one\r\nThis is two";

Return Values

WriteLine Return Values

Return Value

Description

0

Indicates that the function successfully wrote the line to the file.

< 0

Indicates that the function was unable to write the line to the file.

See Also