Home Search

DriveWorks Pro 22
Run Macro in a Loop

Send Feedback

Run Macro in a Loop

The Run Macro in a Loop task will run a Macro in the Specification the number of times specified by the Start, Limit and Increment Values.

Macros cannot be run while editing a project.

Properties

Property NameDescription
TitleChanges the Title (not the name) of the task.
Macro NameThe name of the macro in the project.
Macro Argument

Provides an optional argument to the macro.

Click here for more information...
DeferFalse (default) to run the macro immediately.

True (not recommended) to defer the execution of the macro until after the Specification has been saved.

Using TRUE for the Defer property

  • Setting the property to TRUE is not supported when triggered from a Macro Button control.
  • Setting the property to TRUE is only supported when applied to the Leave Event of a State that transitions to a Paused State.
  • Setting the property to TRUE and running other Tasks within the same Specification Macro is not supported.

When a Specification is created a copy of the Project file (.driveprojx file) is stored alongside it in a hidden folder. This file is saved whenever a Specification is transitioned to a non-running state.

The Defer property controls the timing of when the macro is run.

  • FALSE - executes the macro immediately
  • TRUE - defers the execution until all other Tasks have been run.

When a Specification transitions to a paused state, and the Defer property is set to TRUE, it will run after all other Tasks within the same Task Sequence have been run and all the changed values have been saved to the Project file.

Start ValueControls the initial value of the loop counter.

This defaults to 1 when the Task is added.

Limit ValueControls the limiting value of the loop counter.

This defaults to 10 when the Task is added.

Increment ValueControls the value added to the loop counter on each iteration, this will be positive to step up and negative to step down.

This defaults to 1 when the Task is added.

Counter ConstantOptional. The name of a Constant which will receive the loop counter value on each iteration.

Example

When this task is added the properties are static by default.
See How To: Change A Static Property To A Dynamic Property to enable rules to be built on these properties.

Property NameExample RuleExample ResultMeaning
DeferFALSEFALSEFALSE will run this Task immediately.
DeferTRUETRUETRUE would defer this Task until after the Specification had been saved.
Macro ArgumentDWCurrentMacroArgument1Will be the Macro Argument used by the Macro running in a loop.This can then be used in rules. Find more information here
Macro Name"Export to table"Export to tableThis is the name of the Macro you want to run.
Counter ConstantDWConstantLoopingConstantDWConstantLoopingConstantWill increase the specified Constant every time the loop is carried out.
Increment Value11Will add 1 to the loop counter of each iteration. This is positive so will step up.
Limit ValueTableMaxValue(DWLookupCustomers,1)10The loop counter will be limited to this number of loops. The rule is finding the maximum value that the table goes to and sets that as the limit
Start Value11The loop counter will start at this value

Using the Task in a Specification Macro

This task has different types of Outputs. For more information about Outputs see Specification Macros Task Node.

Outputs are only available within Specification Macros. Currently Outputs are not available for Specification Flow.

Status Outputs

This task supports Status Outputs. These can be used to perform different actions depending on what the status outcome of the task is. For more information see Status Outputs in the Task Node Outputs section of Specification Macros Task Node.

The status output navigation is as follows:

Success

  • Macro was successfully executed in a loop.

Success with Warnings

  • N/A

Failed(One of the following occured)

  • Increment value was invalid.
  • Constant doesn't exist or could not be found.
  • Macro doesn't exist or could not be found.
  • Macro failed to succesfully execute - see the Specification report for more information.

DriveWorks Tech Tips Portal

Copy Table

Shows how you can copy data from one Simple Table to another, remove selected rows and clear the whole table using macros.

View all Tech Tips

DriveWorks Tech Tips Portal is available to DriveWorks Pro customers with an active subscription and support contract.

Tech Tips provide cut down projects that highlight specific functionality for faster and more effective learning.

To access the portal:

  1. Go to https://my.driveworks.co.uk/learn/tech-tips/
  2. Login with your DriveWorks Pro account credentials, if asked
  3. Click the Visit Tech Tips Portal button for access

The portal provides a search facility, start typing the name of the Tech Tip (as indicated above) to display the Tip you require.