This space contains documentation for TrueSight Server Automation 8.9.03 and the later service packs for 8.9. For earlier releases, see BMC Server Automation 8.9.

Defining a loop

Loops enable the iterative analysis of conditions (basic conditions or even conditional constructs) within a group of configuration objects.You can choose from the following types of loops:


Typical example

Expression returns TRUE if...

Foreach Loop

foreach "File:/C/temp/*.log"
 Name starts with "a"

all configuration objects in the specified group fulfill the conditions defined in the loop body

Exists Loop

exists "File:/C/temp/*.log" where
 Name starts with "a"

at least one configuration object from the specified group fulfills the conditions defined in the loop body

Count Loop

count "File:/C/temp/*.log" = 5 where
 Name starts with "a"

the number of configuration objects in the specified group that fulfill the conditions defined in the loop body complies with the count condition in the count loop line

Loops can be combined with conditions or nested within conditional constructs. A loop cannot be nested within another loop.

To define a loop

  1. After selecting the relevant loop option (Foreach Loop, Count Loop, or Exists Loop) through the drop-down arrow beside the New Condition icon, specify the following element in the loop line:
    • The configuration object group — typically an entity that can contain other objects (such as a directory) or a configuration object string containing a wildcard
      For a count loop line, you must also specify the following elements:
    • a comparison operator for Integer-type data (such as equals, does not equal, is one of, greater than, or between)
    • a constant value or values to which to compare, or, alternatively, a parameterized, Integer-type configuration object property or component property
  2. Click Apply Condition Value at the end of the loop line to apply your changes (or, alternatively, leave the loop line by clicking outside of it).
    You can click Cancel Edit Operation to cancel any editing that you performed on the loop line as long as you have not yet applied your changes.
  3. Define a condition in the loop body in the following manner:
    • Select the loop line.
    • Double-click the New Condition icon for a basic condition, or click the drop-down arrow beside this icon and select from the full range of available condition types.
      • Basic Condition for a basic condition
      • If... Then... End for a conditional construct
    • In the displayed fields, define the condition as discussed in one of the following sections:

The most typical condition for inclusion in the loop body is a basic condition that evaluates a property of the configuration object specified in the loop line. You can combine several conditions within the loop body for a more complex expression.

Was this page helpful? Yes No Submitting... Thank you