Write

The WRITE command transfers a character stream specified by its arguments to the current device.

The format of the WRITE command is:

	W[RITE][:tvexpr] expr|*intexpr|fcc[,...]
	

GT.M can write up to 32,767 bytes (the GT.M maximum string length) as a result of a single WRITE argument. GT.M buffers output into a "logical record" for all devices except mailboxes and sockets without DELIMITERs. The WRITE command appends a string to the current record of the current device. GT.M does not write to the output device until the buffer is full, a GT.M format control character forces a write, a USE command, a CLOSE command, or, for terminals, the buffer becomes stale (the terminal staleness timer is adjustable through GTM$DEFAULTS).

Each device has a WIDTH and a LENGTH that define the virtual "page". The WIDTH determines the maximum size of a record for a device, while the LENGTH determines how many records fit on a page. When the current record size ($X) reaches the maximum WIDTH and the device has WRAP enabled, GT.M starts a new record. When the current line ($Y) reaches the maximum LENGTH, GT.M starts a new page.

A WRITE with an asterisk preceding the argument, which it would expect to be a decimal ASCII representation, writes the character corresponding to the ASCII representation. The WRITE command also has several format control characters that allow the manipulation of the virtual cursor. For all I/O devices, the GT.M format control characters do the following:

WRITE !: Clears $X and increments $Y and terminates the logical record in progress. The definition of "logical record" varies from device to device, and is discussed in each device section.

WRITE #: Clears $X and $Y and terminates the logical record in progress.

WRITE ?n: If n is greater than $X, writes n-$X spaces to the device, bringing $X to n. If n is less than or equal to $X, WRITE ?n has no effect. When WRAP is enabled and n exceeds the LENGTH of the line, WRITE ?n increments $Y.

For more information, refer to the sections on specific I/O devices.