Genies are customizable, reusable objects that are even more flexible when used with the IFDEF macro. With the IFDEF macro, during compilation it is able to detect if a Genie substitution is valid or not. If the substitution is not valid you are able to hide it from the page, thus making your Genies more generic and reusable in more contexts.
Note: In Citect SCADA, using the IFDEF macro is considered an advanced configuration scenario.
The expressionA statement (or group of statements) that returns a value. An expression can be a single variable, a mathematical formula, or a function. entered in the Hidden When field of an object's property is used to determine if the object will be visible on the page at runtime. The expression evaluates to either TRUE or FALSE and the object is hidden when the expression is TRUE.
You define the variable tag and conditions under which the object is hidden by entering an IFDEF statement into the Hidden When field when you configure the object. The IFDEF statement is evaluated by the compiler and the value of the resulting expression or variable tag will determine whether or not the object is hidden.
This can significantly reduce the number of necessary Genies, as the configuration engineer does not need to generate several smaller Genies to cater to operations driven by a slightly different range of tags.
The IFDEF statement consists of three arguments:
IFDEF (<"Tag Reference">, <Result value if tag defined>, <Result value if tag undefined>)
The first includes a tag reference (variable tag name or 'Equipment.Item'). If the variable tag is defined in the tag database at project compilation, the IFDEF statement is replaced in the Expression field by the second argument. If the variable tag is undefined, the Expression field will contain the third argument, displaying a value of a tag that may not be defined in your project.
IFDEF("Bit_1", 0, 1)
In the above example, if Bit_1 is defined in the tag database, the value in the Hidden When field will be 0. If Bit_1 is undefined, the value will be 1. Since the object is hidden when the value is TRUE, the object will be hidden when BIT_1 is undefined (i.e. when the Hidden When field contains 1).
IFDEF("Bit_2",,"NA")
If the second argument is omitted, as in Example 2, the variable tag specified in the first argument is used. If Bit_2 is defined, therefore, the display value will contain Bit_2. If the tag is not defined, then NA would be displayed.
If Bit_2 is undefined, the Hidden When expression evaluates to 1 (TRUE) and the object is hidden.
To enter an IFDEF statement in the Hidden When Field:
See Also
Published June 2018