.IF-.ELSE-.ENDC

Perform conditional processing

WSupported on Windows
USupported on Unix
VSupported on OpenVMS
NSupported in Synergy .NET
.IF expression
 [. . .
source_1
   . . .]
[.ELSE
   . . .
[source_2
   . . .]]
.ENDC

expression

One of the following values:

source_1

(optional) One or more lines of source code.

source_2

(optional) One or more lines of source code.

The .IF compilation control directive indicates that the statements that follow are to be compiled if the specified expression is true.

The source_1 lines of code are compiled only if expression is true. If the .ELSE directive is present, the source_2 lines of code are compiled only if expression is false.

You can use one or more of the .ELSE, .IFT, .IFF, and .IFTF directives within an .IF conditional block. These conditional compilation control directives can be nested.

The .ENDC directive must always close an .IF conditional block. If .ENDC is not present, a warning is generated.

Note

Avoid using nested literal fields in .IF and other preprocessor statements because the results could be unexpected. Use .DEFINEs instead to achieve the desired results.

This example shows a simple conditional compilation control operation.

.include "GBL:users.def" 
function authenticate 
record 
    user_ok     ,i4 
proc 
.if ^defined(user.password) 
    user_ok = %userauth(user.password)          ;Authenticate the user 
.else 
    user_ok = %true                             ;Authentication is disabled 
.endc 
    freturn(user_ok) 
endfunction