Caché MultiValue PROC Reference
IF, IFN
[Back] [Next]
   
Server:docs2
Instance:LATEST
User:UnknownUser
 
-
Go to:
Search:    

Conditionally executes a command.
Synopsis
IF condition command
IF condition label
IFN condition command
IFN condition label

where condition:
x {= | # | < | >} y
x {= | #} (patcode)
[#]E
[#]S[n]
Arguments
condition A condition that resolves to a boolean value. If TRUE (1), command is executed. If FALSE (0), command is not executed.
command The command to execute if condition=1 (TRUE).
label An integer specifying the location to go to if condition=1 (TRUE).
Description
The IF PROC command applies a boolean test on a condition statement, and, if the condition is true, either executes the specified command, or goes to the specified label location. A condition is true if any one of the value comparisons are true.
IF performs a string condition comparison. IFN performs a numeric condition comparison.
A condition can use the = (equal to) or # (not equal to) operator. The following conditions are supported:
Compound IF Expressions
You can use the ] character to create compound IF expressions. In a compound expression, the right side of the condition consists of two (or more) match conditions, each of which has its corresponding command or label.
In the following example, the value of x is first compared to all of the values in %3; if any of these match, command1 is executed. If x does not match %3, x is then matched with all of the values in %4; if any of these match, command2 is executed.
IF x = %3]%4 command1]command2
In the following example, the value of x is first compared to the literal Foo; if this is a match, a goto operation is performed to label 100. If x does not match Foo, x is then matched with Bar; if this is a match, a goto operation is performed to label 200.
IF x = Foo]Bar 100]200
See Also