$$IF, $$ELIF, $$ELSE, and $$ENDIF

HomeOverviewsHow Do IDetailsSample

Feature Only in Professional and Enterprise Editions   Creating a Custom AppWizard is supported only in Visual C++ Professional and Enterprise Editions. For more information, see Visual C++ Editions.

$$IF(macro-list)

textA

 $$ELIF(macro-list)

textB

$$ELSE

textC

$$ENDIF

Parameters

macro-list

One or more macro names. A macro name can be preceded by the logical NOT operator (!). Multiple macro names are separated by the logical OR (||) operator. A macro name can be one of the standard MFC AppWizard macros or one that you create by adding it to the dictionary.

Remarks

The $$IF directive, with the $$ELIF, $$ELSE, and $$ENDIF directives, controls the flow of control that the ProcessTemplate function follows while parsing a custom resource template.

When the parser encounters an $$IF directive, it searches the dictionary for each macro name it finds in macro-list, in sequential order. The parser checks only for a macro name’s existence in the dictionary, not its value. Once a macro name is found in the dictionary, the parser stops checking the other macro names, the $$IF evaluates to TRUE, and textA is parsed. If the parser finds none of the macro names in the dictionary, the $$IF evaluates to FALSE and the parser processes any subsequent $$ELIF directive’s macro-list as it did the $$IF macro-list. If an $$ELIF evaluates to TRUE, textB is parsed. If no $$ELIF directive evaluates to TRUE, the $$ELSE body (textC) is parsed. The $$ENDIF directive marks the end of the $$IF construct, and normal parsing resumes with the next line.

In the $$IF and $$ELIF arguments, any macro name can be preceded by the logical NOT operator (!) to force the parser to check for non-existence in the dictionary. For example, the following code fragment evaluates to true if MACRO1 is not in the dictionary:

$$IF(!MACRO1)

Each $$IF directive in a custom resource template must be matched by a closing $$ENDIF directive. Multiple $$ELIF directives can appear between the $$IF and $$ENDIF directives, but at most one $$ELSE directive is allowed. That $$ELSE directive, if present, must follow all the $$ELIFs (if any) in that $$IF-$$ENDIF block. If a custom resource template contains an $$IF, any following $$ELIF and/or $$ELSE is optional. An ending $$ENDIF is mandatory. $$IF constructs can be nested up to five levels deep.

There is no logical AND (&&) operator. If you wish to have text parsed only when MACRO1 and MACRO2 are defined, you can accomplish this as follows:

   $$IF(MACRO1)
   $$IF(MACRO2)
   text
   $$ENDIF //MACRO2
   $$ENDIF //MACRO1

See Also   Standard AppWizard Directives, The Dictionary, CCustomAppWiz::ProcessTemplate, Standard AppWizard Directives, Standard AppWizard Macros