Invokes other preprocessor procedures, and/or produces text. Answered text replaces the invocation of the preprocessor procedure in the source text. The number of ANSWER statements you can use in a preprocessor procedure is unlimited.
>>--ANSWER-----------------------------------------------------------> |+-(-exp1-)-+| |+-PAGE---------------+| |+-SKIP---------------+| |+-(-exp2-)-+| >-------------------------------------------------------------;----->< |+-COLUMN--(-exp3-)-+| |+-MARGINS------------------------+| |+-(-exp4-------------)-+| |+-,-exp5-+|
Abbreviation for ANSWER: ANS
If SCAN or RESCAN is set, the character string is scanned for preprocessor procedure invocations and replacements. The returned replacement is within the scope of the preprocessor procedure and not in the scope where the answered text is returned. Answered text is inserted into the source at the point of the preprocessor invocation. Once the text has been returned into the source, it is not scanned for any replacement activity.
String replacement activity follows the same rules as those for source text scanning and replacement.
Abbreviation: COL
exp5 specifies values that must be within the range returned by the MACLMAR (left margin) and MACRMAR (right margin) built-in functions.
If you omit this option, the default value is MARGINS(MACLMAR,MACRMAR); if you include this option with no operands, the default value is MARGINS(MACCOL,MACRMAR).
Abbreviation: MAR
Use this statement only in a preprocessor procedure that does not also use the RETURNS attribute.
Do not use both the RETURN statement with an expression, and the ANSWER statement within the same preprocessor procedure.
When an expression invokes a macro, and that macro does not return a value, the macro preprocessor assumes that a null string is returned.
%dcl Expression entry; %Expression: procedure; dcl sn fixed; sn = 4; ANS( "IF (X > 3) THEN") col(sn) skip; ANS( "put skip list('x is greater than 3');") col(sn + 2) skip; ANS( "PUT") COL (SN) skip; ANS( "SKIP") COL (SN+6); ANS( "LIST") COL (SN+12); ANS( "('Hello World');") COL (SN+18); %end; foo: proc() options(main); dcl x fixed bin(31) init(4); Expression end;
Generates:
FOO: PROC() OPTIONS(MAIN); DCL X FIXED BIN(31) INIT(4); IF (X > 3) THEN put skip list('x is greater than 3'); PUT SKIP LIST ('Hello World'); END;