<< Click to Display Table of Contents >> Navigation: Macros > Macro commands and parameters > Macro loop commands |
A loop command is used to perform an action repeatedly, as long as a particular condition is met. A loop occupies several lines of a macro. Two values are compared and, depending on the outcome, the relevant part of the macro is executed, repeatedly executed or skipped. Using a loop, it is possible, for example, to perform an action in connection with all selected components or to keep on performing as long as two specified values are equal.
The following loop commands may be used:
•While … End: keep executing the relevant part of the macro as long as a particular condition is met
•Repeat … Until: execute the relevant part of the macro repeatedly until a particular condition is met
•Loop ... End: execute the relevant part of the macro for a variable, stepping from start value to end value
•For … End: execute the relevant part of the macro for all objects of a particular type
•ForSelection … End: execute the relevant part of the macro for all objects of a particular type within a Selection
To prevent a macro accidentally getting stuck in an endless loop, it is possible to assign two types of protective value. One is the maximum number of loop iterations; the other is the maximum time for which execution should be continued. These protective values are set in the Options, using Calculation | Macro.