Using the WRITE and WRITENR statements
Two CLIST statements are available for sending messages to the
terminal and prompting for input:
- WRITE displays a message at the terminal and causes the terminal's display cursor to return to the beginning of the next line after the message is displayed.
- WRITENR displays a message at the terminal and causes the terminal's
display cursor to remain at the end of the message. (The
NR
in WRITENR is forNo Return
.)
When prompting the user for input, include a READ statement after the WRITE or WRITENR statement. The READ statement reads the user input into a variable or variables. For more information, see Using the READ statement.
Both WRITE and WRITENR must be followed by one or more blanks and
the text of the message. For example:
CONTROL ASIS
⋮
WRITE Your previous entry was invalid.
WRITE Do you want to continue?
WRITENR Enter yes or no.As a result of these statements, the terminal user sees the following
messages on the screen:
Your previous entry was invalid.
Do you want to continue?
Enter yes or no. __
The cursor stops after the period in the last line to indicate the CLIST is waiting for the user's response. Because CONTROL ASIS is specified the CLIST displays the message ‘as written’, in both uppercase and lowercase letters.
You can also use the WRITENR statement to join text. For example:
CONTROL CAPS
⋮
WRITENR Please enter your userid
WRITE followed by two blanks. As a result of these statements,
the terminal user sees the following message:
PLEASE ENTER YOUR USERID FOLLOWED BY TWO BLANKS.
Because CONTROL CAPS is specified, the message is translated to all capital letters before being displayed.