WRITES

Write the next sequential record to a channel

WTSupported in traditional Synergy on Windows
WNSupported in Synergy .NET on Windows
USupported on UNIX
VSupported on OpenVMS
WRITES(channel, data_area[, label][, GETRFA:new_rfa]) [[error_list]]

Arguments

channel

The channel on which the file is open. The channel must already have been opened in output, append, or update mode. (n)

data_area

An expression that contains the information to be written. (a)

label

(optional) The label to which control is transferred if the output device is full.

GETRFA

(optional) Returns the record’s RFA after the WRITES has been performed. See GETRFA for a complete description.

error_list

(optional) An I/O error list. If any one of the specified errors occurs as part of the WRITES, control is transferred to the associated label.

Discussion

The WRITES statement is only supported for non-ISAM files.

The WRITES statement writes the record immediately following the most recent record that was read from or written to the output file to a specified channel. It also appends a record terminator to the data area written.

After the WRITES, any automatic record locks are released.

When using xfServer, setting the SCSPREFETCH environment variable turns on record buffering for the WRITES statement.

If you have a telnet terminal connection, see $ERR_IOFAIL for more information.

Examples

The following example scans through a file, extracting the name field into a separate list file.

subroutine find_rec
    a_chn               ,d              ;Input file channel
.include "REC:who.rec"                  ;Record "who" includes field "name"
.define TMPCHN          ,99
record
    list_file           ,a*,    "WRK:name.lst"

proc
    xcall flags(4020, 1)
    open(TMPCHN, o, list_file)
    repeat
      begin
        reads(a_chn, who, done)
        writes(TMPCHN, name)
      end
done,
    close TMPCHN
    xreturn
endsubroutine