SAY

In this section:

How to:

Reference:

The SAY command writes messages to a file or to the default output device. You can use SAY for application debugging, such as tracing application control flow, and for recording an accounting trail. To display messages to application users, you should use forms, which provide superior display capabilities and better control than the SAY command.

Syntax: How to Use the SAY Command

The syntax of the SAY command is

SAY [TO ddname] expression [expression ...] ;

where:

TO ddname

Specifies the logical name of the file to which the SAY message is written. ddname is a character expression. If you supply a literal for ddname, it must be enclosed in single quotation marks (') or double quotation marks (").

You must define the logical name using a DYNAM command on z/OS before the SAY command is executed. In order to append to an existing file (for example, to write to a file from more than one procedure), specify the appropriate option in the DYNAM command.

If TO ddname is omitted, the message is written to the default output device of the environment in which the SAY command is issued.

In addition, if TO ddname is omitted and this procedure was called remotely (that is, called using a CALL procname command), the message will also be copied to the FocMsg stack of the calling procedure.

expression

Is any Maintain Data expression. Multiple expressions must be separated by spaces.

Each message is written on the current line, beginning in the column that follows the end of the previous message. When a message reaches the end of the current line in the file or display device, or encounters a line feed (the string \n) in the message text, the message stream continues in column 1 of the next line.

If you write to output devices that buffer messages before displaying them, you may need to end each message with an explicit line feed to force the buffer to display the last line of the message.

Note: Literals must be enclosed in single quotation marks (') or double quotation marks ("), while variables do not appear in quotation marks.

Reference: Commands Related to SAY

TYPE. Writes messages to a file or to a form.

Writing Segment and Stack Values

You can use the SEG and STACK prefixes to write the values of all the fields of a segment or columns of a stack to a message. This can be helpful when you write messages to log and checkpoint files.

SEG.fieldname inserts Current Area values for all of the fields of the specified segment. STACK.stackname(row) inserts, for the specified stack, the values of the specified row.

Choosing Between the SAY and TYPE Commands

The rules for specifying messages using the SAY command are simpler and more powerful than those for the TYPE command. For example, you can include all kinds of expressions in a SAY command, but you can only include character string constants and scalar variables in a TYPE command.

Note that, unlike the TYPE command, the SAY command does not generate a default line feed at the end of each line.