write Method

Class: IO

Description

This method writes a record to the device defined by the fileName and directory IO class properties. To use this method, the openParams property must contain WRITE.

 

A default carriage return line feed appears after each record to separate the records. You can, however, specify a different separator as the EOLChar parameter in the write method.

 

If the charsetName property contains a non-empty value, then characters in recordData and EOLChar is translated from Runtime.charsetName to IO.charsetName.

Syntax

do objectName.write(String recordData,String EOLChar)

Parameters

recordData

Actual or variable data to write to the device. If a variable is used, you must pass this value by reference.

EOLChar

An optional end-of-line character to place after each record. The default is the line terminator of the underlying operating system.

To suppress EOL, pass the empty string in the EOLChar parameter.

Returns

None

When Became Available

v6.4

Example

type IO io = Class.new(“IO”)

set io.directory = ”/unix_directory/spool”

set io.fileName = ”TEST.txt”

set io.openParams = ”NEWV/WRITE”

set io.timeout = 5

 

do io.open()

type String TEXT

set TEXT=”This is a file created using IO class methods.”

do io.write(TEXT)              // default EOL

do io.write(TEXT,"")           // no EOL

do io.write("")                // only EOL

do io.write(TEXT,$CHAR(13,10)) // EOL required by HTTP

do io.close()

 

*The value of the device property must be a valid file, and the user must have write access to the file.