Using the READ statement
The READ statement makes terminal input available to a CLIST in the form of symbolic variables. You normally precede a READ statement with one or more WRITE or WRITENR statements to let the user know that the CLIST is expecting input, and what sort of input it is expecting.
You can include one or more symbolic variables on a READ statement. If a READ statement does not include any variables, the CLIST stores the information the user enters into the control variable &SYSDVAL.
READ A,B,C,DNote that variables on a READ statement do not require ampersands.
SMITH,JONES,KELLY,INGALLS,GREENE&A has the value SMITH.
&B has the value JONES.
&C has the value KELLY.
&D has the value INGALLS.Because the READ statement only includes four variables, the CLIST ignores the fifth name (GREENE).
READSMITH,JONES,KELLY,INGALLS,GREENE, &SYSDVAL has the following value:
SMITH,JONES,KELLY,INGALLS,GREENEREAD NUM1,NUM2,NUM3,NUM415,24,,73 or
'15' '24' '' '73'&NUM1 has the value 15.
&NUM2 has the value 24.
&NUM3 has a null value.
&NUM4 has the value 73.The fact that single quotation marks are valid delimiters requires that you exercise care when reading fully-qualified data set names into variables. Precautions are necessary because, if the user enters the data set name within single quotation marks (according to TSO/E naming conventions), the CLIST normally reads them as delimiters, not data. If a WRITE statement requests the name of a fully-qualified data set, the CLIST can obtain the data set name as entered by the user, with single quotation marks preserved, by using the READ statement with the &SYSDVAL control variable.
PROC 0
WRITE Enter the name of a data set.
READ
SET &DSN = &SYSDVAL /* Get name from &SYSDVAL; */
IF &SUBSTR(1:1,&DSN) ¬= &STR(') THEN +
DO /* If not fully qualified, */
SET &DSN = '&SYSPREF;.&DSN' /* add prefix and quotation marks. */
END
WRITE &DSN PROC 0 ALPHA()
⋮
SET SPACEVENTS = &ALPHA
DO WHILE &SPACEVENTS = /* Null */
WRITE Enter the number of golf balls there
WRITE are on the moon. A null value is unacceptable.
READ ALPHA
SET SPACEVENTS = &ALPHA
END If a user ends a line of READ input with a plus
sign or hyphen, the READ statement treats it as a continuation symbol
and waits for another line of input. For more information, see Continuation symbols.