AIM I/O operations center around a stream ID that identifies an open I/O device. The stream ID is returned when an I/O device is open. It must be passed to any subsequent I/O statements that refer to the open device.
A protocol also is associated with each I/O device. The protocol identifies the method used to open and close the I/O device. It also specifies the format for reading data from or writing data to the device. (The protocol determines how communication is performed and how data is formatted.)
The IO_OPEN statement is used to open an I/O device for subsequent I/O operations. The statement waits until the open operation is complete before returning a completion status code.
Multiple AIM tasks may access the same device. (The device is opened when the first task accesses the device.) To do this, the MODE argument must be the same for each AIM task that is accessing the device.
IO_OPEN PROTOCOL --protocol-- IO_DEVICE {--s_uopr--}
--string_var-- {--s_opr-- --string_var-- {--s_opr--
--string_var-- {--s_opr-- --string_var--}}} MODE
--I/O_mode STREAM --o_variable-- {STATUS --o_variable--}
PROTOCOL is a keyword that is selected from a list of protocols defined in the I/O initialization database.
IO_DEVICE is a string expression using up to four string variables that specify the device, path, and filename as required by the selected protocol.
MODE is a keyword that is used by the protocol to determine the I/O open mode. This keyword is selected from a list of modes (read, write, or read_write).
STREAM is an output variable that receives an ID code used for subsequent I/O operations.
STATUS is an output variable that receives the I/O completion status code for the operation.
The IO_CLOSE statement is used to close the I/O device or file associated with an I/O stream and to free any associated system resources.
If multiple AIM tasks have opened this stream, the stream is not closed until the last task closes the stream. The last task waits until the close operation is complete before returning a completion status code.
NOTE: After this statement is executed, the stream ID should not be used for I/O by the task.
IO_CLOSE STREAM --variable-- {STATUS --o_variable--}
STREAM is a variable that specifies the I/O stream to be closed.
STATUS is an output variable that receives the I/O completion status code for the operation.
The IO_READ statement is used to read data from an I/O stream while waiting for the specified time-out.
IO_READ STREAM --variable-- {RECORD_NUMBER --variable--} {TIMEOUT
--variable--} DATA --o_variable-- {, --o_variable-- {,
--o_variable-- {, --o_variable-- {,--o_variable-- {,
--o_variable-- {, --o_variable-- {,--o_variable-- {,
--o_variable-- {, --o_variable--}}}}}}}}}
{STATUS --o_variable--}
STREAM is a variable that specifies an open I/O stream. Normally, the stream must be open for read or for read-write.
RECORD_NUMBER is used to specify the number of the record to be read. It is used only if it is supported by the I/O protocol.
TIMEOUT is used to specify the maximum number of seconds to wait for the read operation to complete. If this value is not specified, the statement waits indefinitely.
DATA is from 1 to 10 output variables that receive the data from the I/O device. The data format is specified by the protocol. The data is returned as strings, but is automatically converted to numeric data if numeric variables are specified.
STATUS is an output variable that receives the I/O completion status code for the operation.
The IO_WRITE statement is used to write data to an I/O stream.
IO_WRITE STREAM --variable-- {RECORD_NUMBER --variable--} DATA
--variable-- {, --variable-- {, --variable-- {, --variable-- {,
--variable-- {, --variable-- {, --variable-- {, --variable-- {,
--variable-- {, --variable--}}}}}}}}} {STATUS --o_variable--}
STREAM is a variable that specifies an open I/O stream. Normally, the stream must be open for write or for read-write.
RECORD_NUMBER is used to specify the number of the record to be written. It is used only if it is supported by the I/O protocol.
DATA is from 1 to 10 output variables that contain the data to be written to the I/O device. The data format is specified by the protocol. The data is sent to the driver task as ASCII strings. If numeric variables are specified, they are automatically converted to strings using the V+ default (/D) format.
STATUS is an output variable that receives the I/O completion status code for the operation.