HPlogo MPE/iX Intrinsics Reference Manual > Chapter 6 Command Definitions (FLUSHLOG-GETUSERMODE)

FWRITE

MPE documents

Complete PDF
Table of Contents
Index

Edition 7 E0701 ♥
Edition 7 E0300
Edition 6 E0195

NM and CM callable.

Writes a logical or physical record or portion of a record from the stack to a file on any device.

Syntax



          I16V     UDS     I16V    U16V
  FWRITE (filenum, buffer, length, controlcode);

Parameters


filenum

16-bit signed integer by value (required)

Passes the file number of the file to be written on.

buffer

user-defined structure (required)

Passes the record to be written.

length

16-bit signed integer by value (required)

Passes the number of half words or bytes to be written to the record. If this value is positive, it signifies half words; if negative, bytes. Zero indicates that no transfer occurs.

If length is less than the recsize parameter associated with the record, only the first length (half words or bytes) is written.

If length is larger than the logical record size and NOBUF (aoption in FOPEN/HPFOPEN) is not specified, the FWRITE request is refused and CCL (1) is returned. If NOBUF is specified, length cannot exceed the physical record size unless the multirecord aoption is specified also.

If the multirecord aoption in FOPEN/HPFOPEN is specified, the excess half words or bytes are written to succeeding physical records and carriage-control is specified, the actual data transferred is limited to recsize minus one byte.

(ASC) For asynchronous devices, the physical data transfer is byte-by-byte. If half words are specified, an even number of bytes is output.

controlcode

16-bit unsigned integer by value (required)

Passes a carriage-control code, effective if the file is transferred to a line printer or terminal (including a spooled file whose destination is a line printer or a terminal). This parameter is effective only for files opened with carriage-control specified.

The options are:

0Print the full record transferred, using single spacing. This results in a maximum of 132 characters per printed line.
1Use the first character of the data written to satisfy space control and suppress this character on the printed output. This results in a maximum of 132 characters of data per printed line.

Use any octal code from Table 6-2 "Carriage Control Directives" to determine space control and print the full record transferred. This results in a maximum of 132 characters per printed line.

If the controlcode parameter is not 0 or 1, and length is 0, only the space control is executed and no data is transferred.

Determine whether the carriage-control directive takes effect before printing (prespace movement) or after printing (postspace movement), with the FCONTROL intrinsic.

For spooled files, use FWRITE instead of FCONTROL to set the prespace/postspace control and the auto/no auto page eject control; use control codes %100 through %103 and %400 through %403 for this. If one of the above controls is specified with length=0, no physical I/O occurs.

When a file is opened with CCTL, use the carriage-control codes in one of the following ways:

  • As the value of the controlcode parameter.

  • When controlcode=1, as the first byte of the buffer array.

The default carriage-control code is postspacing with automatic page eject. This applies to all Hewlett-Packard subsystems except FORTRAN 77/XL and COBOLII/XL (these have prespacing with automatic page eject).


NOTE: Channel assignments shown in Table 6-2 "Carriage Control Directives" are the Hewlett-Packard standard defaults.

(KSAM) This parameter must be specified to satisfy internal requirements, but it is ignored.


Table 6-2 Carriage Control Directives


NOTE: If octal codes %55 and %60 are selected with automatic page eject in effect (by default or following an octal code of %102 or %402), the resulting skip is to a location absolute to the page. A code of %60 is replaced by %303, and a code of %55 is replaced by %304. Therefore, the resulting skip can be less than two or three lines, respectively.

If automatic page eject is not in effect, a true double or triple space results, but the perforation between pages is not automatically skipped. For the Hewlett-Packard 2608S and 2563A, if auto-eject and feature mode are in effect, a code of %60 is replaced by two codes of %302, and a code of %55 is replaced by three codes of %302. The resulting skip is double or triple space with auto-eject, respectively.

Figure 6-2 Carriage-Control Data

[Carriage-Control Data]

Operation Notes


If information is written to a fixed-length record and the NOBUF aoption in FOPEN/HPFOPEN is not specified, any unused portion of the record is padded with binary zeros or ASCII blanks.

When the FWRITE intrinsic is executed, the logical record pointer is set to the record immediately following the record just written, or to the first logical record in the next block for NOBUF files. If RIO access is used, the modified record is set to the ACTIVE state.

When an FWRITE call writes a record beyond the current logical end-of-file indicator, this indicator is advanced. However, this is noted in the file label only when the file is closed or when an extent is allocated. If the physical bounds of the file are reached, CCG (0) is returned.

If a magnetic tape is unlabeled (as specified in the FOPEN/HPFOPEN intrinsic, or in the FILE command) and the program attempts to write over or beyond the physical or simulated end-of-tape (EOT) marker, the FWRITE intrinsic returns CCL (1). The actual data is written to the tape, and a call to FCHECK reveals an end-of-tape file error. After the EOT marker is crossed, all writes to the tape transfer the data successfully but return CCL (1) until the tape crosses the EOT marker again in the reverse direction (rewind or backspace).

If a magnetic tape is labeled (as specified in the FOPEN/HPFOPEN intrinsic, or in the FILE command), CCL (1) is not returned when the tape passes the EOT marker. Attempts to write to the tape after an EOT marker cause end-of-volume (EOV) markers to be written. A message is printed on the system console requesting another volume (reel of tape) be mounted.

For message files and circular files, this intrinsic logically appends the record to the end of the file. If a circular file is full, the first block is deleted, the remaining blocks are logically shifted to the file's head, and the new record is appended to the end of the file. If a message file is full and there are no readers, the process waits if there is an FCONTROL=45 in effect or if this is the first FWRITE after an FOPEN/HPFOPEN call. Otherwise, CCG (0) is returned.

Control codes are ignored for byte stream files. Byte stream files can not be opened with carriage control.

Condition Codes


CCE (2)Request granted.
CCG (0)Request denied. The physical bounds of the file prevented further writing.
CCL (1)Request denied. An error occurred; length exceeded the size of the record in nonmultirecord mode, the FSETMODE option was enabled to signify recovered tape errors, or the end-of-tape marker was sensed. If the file is being written to a multivolume labeled magnetic tape set, CCL (1) is not returned when the end-of-tape marker is sensed. Instead, end-of-volume labels are written, and a request is issued to mount the next volume.

Related Information


Intrinsics FUPDATE, FWRITEDIR, FWRITELABEL, FCONTROL, FDEVICECONTROL, FREAD, FSETMODE, IODONTWAIT, IOWAIT, RESETCONTROL, XCONTRAP
Manuals Accessing Files Programmer's Guide




FUPDATE


FWRITEDIR