.IF-.ELSE-.ENDC
Perform conditional processing
WTSupported in traditional Synergy on Windows
|
WNSupported in Synergy .NET on Windows
|
USupported on UNIX
|
VSupported on OpenVMS
|
.IF expression [. . . source_1 . . .] [.ELSE . . . [source_2 . . .]] .ENDC
Arguments
expression
One of the following values:
- A string, number, or implied-decimal number
- Any compile-time expression, except one containing ^SIZE or ^ARGNUM. (See Compile-time expressions and optimizations for a complete list of functions that are evaluated at compile time.)
- A macro variable that expands to one of the above
source_1
(optional) One or more lines of source code.
source_2
(optional) One or more lines of source code.
Discussion
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.
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. |
Examples
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