#If function

Syntax

#If directive_expression #Then
   statement_list
[#Else
   statement_list]
#End-If

Description

Use the #If construct to compile PeopleCode statements conditionally, depending on the evaluation of the directive conditional expression. Similar to regular If-Then-Else structures, the #Then and #Else clauses of an #If structure consist of arbitrary lists of statements. The #Else clause is optional and may be omitted. If the directive condition evaluates to True, all statements in the #Then clause are compiled; otherwise, all statements in the #Else clause are compiled.

Note:

During compilation, the entire directive block that evaluates to False is treated as a PeopleCode comment. This PeopleCode comment has a special limit of 32,766 characters (unlike regular PeopleCode comments which are limited to 16,383 characters). If your PeopleCode program has a block that evaluates to False that is greater than 32,766 characters, you will be unable to save your program and will receive an error message.

Parameters

Parameter Description

directive_expression

Specifies a directive function (for example, #ToolsRel) in a standard comparison that evaluates to a Boolean value.

To combine multiple directive expressions, use && (AND) or || (OR) as the Boolean operators.

Note: && and || cannot be used in parentheses.

Returns

None.

Example

Note:

Unlike regular If structures, a semicolon separator is not required after an #End-If.

In the following example, the #If block is compiled for an version of PeopleTools greater than or equal to 8.54.00. The #Else block is compiled for any other versions of PeopleTools.

#If #ToolsRel >= "8.54" #Then
   ...
   MessageBox(0, "", 0, 0, "PeopleTools version 8.54 and above");
#Else
...
Messagebox(0, "" , 0 , 0, "PeopleTools version less than 8.54");
#End-If

In the following example, the #If block is compiled for specific patch levels: 8.54.01 and 8.54.02. The #Else block is compiled for any other versions of PeopleTools.

#If #ToolsRel >= "8.54.01" && #ToolsRel < "8.54.03" #Then 
   ...
#Else
...
#End-If