Rational Developer for System z
Enterprise PL/I for z/OS, Version 3.8, Language Reference Manual

Preprocessor ANSWER Statement

The preprocessor ANSWER statement can be used only in a preprocessor procedure that does not have the RETURNS attribute.

The ANSWER statement produces text and/or invokes other preprocessor procedures. The answered text replaces the invocation of the preprocessor procedure in the source text. You can use any number of ANSWER statements in a preprocessor procedure.

Read syntax diagramSkip visual syntax diagram>>-ANSWER--+------------+--+----------------------+------------->
           '-(--exp1--)-'  +-PAGE-----------------+
                           '-SKIP--+------------+-'
                                   '-(--exp2--)-'
 
>--+--------------------+--------------------------------------->
   '-COLUMN--(--exp3--)-'
 
>--+--------------------------------------+--;-----------------><
   '-MARGINS--+-------------------------+-'
              '-(--exp4--+---------+--)-'
                         '-,--exp5-'
 

Abbreviations: ANS for ANSWER, COL for COLUMN, MAR for MARGINS

exp1
Represents a character expression that represents the ANSWER text. The ANSWER text can be either a single character string constant or a preprocessor expression of any complexity.

If it is an expression, the expression evaluation occurs in the usual manner and the result is converted to a single character string.

If SCAN or RESCAN is in effect, the character string is scanned for replacements and preprocessor procedure invocations. This replacement is done within the scope of the preprocessor procedure and not in the scope into which the answered text is returned. The answered text is then inserted into the source at the point of the preprocessor invocation. After the text is returned into the source, it is not scanned for any replacement activity.

Replacement activity in the string follows the same rules as those for source text scanning and replacement. See Example.

PAGE
Forces the answer text to be placed on a new page of the output source by generating a %PAGE directive.
SKIP
Forces the answer text to be placed on a new line of the output source. The value of exp2 represents the arithmetic expression specifying the number of lines to be skipped. If exp2 is not specified, the default value is 1.
COLUMN
Specifies the starting column in the source program line in which the answer text is placed. The value of exp3 represents the arithmetic expression for the column number of the source program line where the answer text starts.
MARGINS
Specifies where the output text is placed within the output record. The value of exp4 represents the arithmetic expression for the left margin for the output text. The value of exp5 represents the arithmetic expression for the right margin for the output text.

The values specified for exp5 must be within the range returned by the MACLMAR (left margin) and MACRMAR (right margin) built-in functions.

If you do not specify the MARGINS option for an ANSWER statement, the default value is MARGINS(MACLMAR,MACRMAR); if you specify the MARGINS option with no operands, the default value is MARGINS(MACCOL,MACRMAR).

You must not use both the RETURN statement with an expression and the ANSWER statement within the same preprocessor procedure.

Example

  %dcl (Expression, Single_string) entry;
  %dcl (Deactivated_macro, Statement_function) entry;
  %dcl Deactivated_variable character;
  %deact Deactivated_variable, Deactivated_macro;
  %Deactivated_variable = '** value of deactivated variable **';

  %Deactivated_macro: procedure returns( character );
     return( '** value of deactivated macro **' );
  %end;

  %Statement_function: procedure( key1 ) stmt returns( fixed );
     dcl key1 fixed;
     return( key1 + key1 );
  %end;

  %Expression: procedure;
     ANS( Counter ) skip;
     ANS( Deactivated_macro ) skip;
     ANS( Deactivated_variable ) skip;
     /* The following is invalid:                                    */
     /* ANS( Statement_function Key1(7););                           */
  %end;

  %Single_string: procedure;
     ANS( 'Counter' ) skip;
     ANS( 'Deactivated_macro' ) skip;
     ANS( 'Deactivated_variable' ) skip;
     ANS( 'Statement_function Key1( 7 );' ) skip;
  %end;


  Expression               /* Generates:                            */
                           /*   00001                               */
                           /*   ** value of deactivated macro **    */
                           /*   ** value of deactivated variable ** */

  Single_string            /* Generates:                            */
                           /*   Counter                             */
                           /*   Deactivated_macro                   */
                           /*   Deactivated_variable                */
                           /*         14                            */

Terms of use | Feedback

This information center is powered by Eclipse technology. (http://www.eclipse.org)