Building Complex Rule Expressions

InstallAnywhere 2018

InstallAnywhere lets you define an unlimited number of rules and assign them to installers, files, panels, consoles, actions, and action groups. The location in the Advanced Designer where you define rules varies, depending on the item to which you are assigning it:

Installers—To evaluate a rule before any installation takes place, use the Manage Expressions view on the Project page or the Installer Rules view on the Project page. The Manage Expressions view on the Project page lets you create and save complex expressions. For more information see Using the Rules Manager to Create Complex Rule Expressions at the Project Level.
Files, Panels, Consoles, Actions, Action Groups—To evaluate a rule for a file, panel, console, action, or action group, assign it on the Rules tab of the item customizer in the appropriate view on the Sequence page.

When you click the Add Rule button to add a rule to an item, the rule is listed, and the rule’s unique ID (which is based on a combination of the abbreviation of the name of the rule and a numeric identifier) is displayed in the Rule Expression field.

Important • When you add a rule, InstallAnywhere automatically generates a unique ID for the rule. However, you can edit these rule IDs both in the Rule Expression field and in the ID column of the Rules table. If you edit these IDs, note the following:

Make sure that the rule ID listed in the Rule Expression field matches the rule ID listed in the ID column of the Rules table.
Make sure that two different rules do not use the same rule ID.

If you want to write complex rule expressions, you can edit the expression in the Rule Expression field to use multiple logical operators (such as AND, OR, and NOT) and precedence operators (parentheses) to express the relationship between two or more rules. By default, rules are joined by the AND operator.

The following is an example of a complex rule expression:

Rule1 AND Rule2 OR (Rule3 AND NOT Rule4)

For the logical operators, use the following symbols:

Logical Operators

Symbol

Operator

Description

&&

and

Both rules must evaluate as true for the installer to continue. If any rule fails to pass, the installer stops and issues the failure message.

||

or

At least one of the rules must evaluate to true. If none of the rules pass, the installer stops and issues the failure message.

!

not

At least one of the rules must evaluate to false. If all of the rules pass, the installer stops and issues the failure message.

Therefore, the sample complex rule expression shown above would be written as:

Rule1 && Rule2 || (Rule3 && ! Rule4)

In the Rules Expression field, rules are represented by unique ID numbers, so this sample complex rule would look like this:

CP799 && CSA304 || (CL990 && ! CIAVN203)

Tip • It is possible to create one rule set for an action group while setting secondary rules on the individual actions within the action group. This approach can yield robust, nuanced conditions in the installer. For more information, see Assigning a Rule to a Group of Actions.

Note • The scope of the rule expression being formed is limited to the files, panels, consoles, actions, and action groups to which the rules have been added.

Validation of Complex Rule Expressions

You can choose to validate complex rule expressions both at design time and at build time.

Validation at Design Time

To validate a rule expression when you are defining it in the Advanced Designer, click the Validate Rule Expression button. InstallAnywhere indicates above the rule whether the rule expression is valid.

To clear all content in the Rule Expression field, click the Clear Rule Expression button.

Validation at Build Time

InstallAnywhere performs rule validation when a project is built. An invalid rule does not prevent the build from completing. However, it does trigger a warning message on the Building dialog box (or the console); the warning message indicates the sequence where the validation failed. If the validation of a rule fails, it is not evaluated at run time.

See Also