Kbase P47076: 4GL/ABL: How to conditionally include a file in a procedure.
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  03/06/2008 |
|
Status: Verified
GOAL:
4GL/ABL: How to conditionally include a file in a procedure.
GOAL:
How to compile a block only depending on some specific conditions.
GOAL:
How to achieve conditional compilation of a block of code?
FACT(s) (Environment):
Progress 8.x
Progress 9.x
OpenEdge 10.x
All Supported Operating Systems
FIX:
Use the &IF preprocessor directive to conditionally compile a block of code or to conditionally include a file in the procedure. Examples:
1. In the following example, the include.i file will be included in the code of the procedure and compiled at compile time if the LOGICAL preprocessor name, that is the compile-time constant {&UserType} is TRUE.
&GLOBAL-DEFINE UserType TRUE
&IF {&UserType} &THEN
{include.i}
&ENDIF
In the following example, the block enclosed in the &IF, &THEN, and &ENDIF preprocessor directives will be included in the code of the procedure and compiled at compile time if the INTEGER preprocessor name, also referred to as the compile-time constant {&Alpha} is even.
&GLOBAL-DEFINE Alpha 12345
&IF {&Alpha} MODULO 2 = 0 &THEN
DEFINE VARIABLE iVar AS INTEGER NO-UNDO.
DO iVar = 1 TO 10:
iVar = iVar + 1.
END.
MESSAGE iVar
VIEW-AS ALERT-BOX INFO BUTTONS OK.
&ENDIF