Skip to main content

WRITE Command

WRITE Command

Writes zero or more characters to the terminal.

Syntax

WRITE *variable 
WRITE *-n
WRITE # 
WRITE /mnemonic

where

Argument Definition
(none) WRITE with no arguments writes all local variables on the current device.
*variable WRITE *variable writes one character, whose decimal value equals x. The value of variable should be an integer in the range 0 to 255 for ASCII characters, and >255 for Unicode characters. By convention, values from 0 to 127 signify 7 bit ASCII characters, while 128 to 255, which represent the extended ASCII character set, relate to the application itself. If the hardware and software are properly set, InterSystems IRIS can handle 8 bit data. Example : You can use the eighth bit to represent international character sets. InterSystems IRIS routines often use WRITE * to send control characters for device dependent functions. Example : WRITE *27,*91,*50,*74 clears the terminal screen. WRITE * does not change $X or $Y; the assumption is that WRITE * output is highly specific to the output device.
*-1

WRITE *-1 clears the input buffer when the next READ is issued. It clears any characters that are pending for the next READ command. Thus all type-ahead characters are cleared.

An input buffer holds characters as they arrive from the keyboard, even those you type before the routine executes a READ command. Thus you can answer questions even before they appear on the screen. When the READ command takes characters from the buffer, InterSystems IRIS echoes them back to the terminal so that questions and answers appear together. When a routine detects errors, it may issue WRITE *-1 to cancel these answers.

*-10

WRITE *-10 clears the input buffer immediately. It does not wait for the next READ command. Thus it clears all type-ahead characters issued before the WRITE *-10; type-ahead characters issed after the WRITE *-10 remain in the input buffer for use by the next READ.

# Issuing WRITE # to a CRT terminal clears the screen and sends the cursor to the home (0,0) position. For a hardcopy terminal, it writes a Carriage Return and Form Feed. WRITE # sets $Y to 0.
/mnemonic Issuing WRITE /mnemonic causes InterSystems IRIS to interpret mnemonic as defined in the active mnemonic space. If there is no active mnemonic space, an error results. You can specify the active mnemonic space in two ways: By naming a default mnemonic space for each device type using the Namespace and Network Configuration editor by specifying a mnemonic space in the OPEN or USE command for the device. For more information, see Controlling Devices with Mnemonic Spaces.

For more information, see WRITE in the ObjectScript Language Reference.

Examples

In the following example, WRITE * rings the bell on the user’s terminal, displays a prompt, and clears the input buffer of any characters received but not yet used.

   SET eek="No. I can't accept that reply" 
   WRITE *7,eek,*-10

The following two examples show the difference between WRITE *-1 and WRITE *-10. In both cases, the user responds to the first READ and presses ENTER, then types ahead during the two pauses caused by the HANG commands:

  READ "type:",x HANG 4 WRITE *-1 HANG 4 READ "type:",y

In the above example, InterSystems IRIS clears the input buffer when the second READ is issued. Thus any text typed during either HANG is cleared from the buffer.

  READ "type:",x HANG 4 WRITE *-10 HANG 4 READ "type:",y

In the above example, InterSystems IRIS immediately clears the input buffer when WRITE *-10 is issued. Thus any text typed during the first HANG is cleared, but any text typed during the second HANG is supplied to the second READ command.

In the following example, WRITE /mnemonic uses the control mnemonic CUP (CUrsor Position) to move the cursor to the third column of the fourth line on the Terminal. In this example, the predefined mnemonic space ^%X364 is specified in the USE command, and the name of an open Terminal device is specified using the terminal variable. See Predefined Mnemonic Spaces for Terminals for a description of ^%X364.

   USE terminal:(80:"BP"):"%X364"
   SET %1=3,%2=4
   WRITE /CUP(%1,%2)
FeedbackOpens in a new tab