Recording Macro code#

If you need to continuously repeat a series of operations or computations in Rulex Factory, you can record these operations as a macro code in the development phase. Successive users can then reproduce these operations by launching the specific event or the specific Macro Resource, hence hiding the complexity of the underlying flow when necessary.

A practical example of a business application of events/macros is the feedback loop, when you want the results of an operation to be used as the partial import of the same loop. You must then frequently recompute the flow, in the right order, each time new data arrives. A Macro code, saving the computations, can make this operation easy and foolproof.

Not only computations can be stored in a Macro code. As explained here, when the record a macro functionality is activated, any operation for which there’s an API/CLI form, is then recorded as Macro code.

This set of operations contains computation in all the computation modes but also all the topology operations:

  • Addition/Deletion of tasks

  • Addition/Deletion of links

As well as modifications of task options or manager task history.

As seen in the events section and in the macro resource page, a macro code can then be saved at flow level in a custom event or at environment level as a saved macro.

Therefore, at the end of the recording phase, the user should decide in which of the two forms the just recorded macro code must be stored. For Macro Resource, then the user must select the environment where the new resource needs to be created, while for events, the new event will be added to the current flow.

Procedure

  1. Click the Record Macro icon in the toolbar.

  2. Perform the group of operations you want to record in your macro.

  3. Click the Stop recording icon in the toolbar when you have finished your operations.

  4. Select Environment Saved Macro and click Save.

  5. Select the environment where you want to save the new resource.

  6. Click Ok to complete the resource creation process.


Configuring an event#

After you have recorded the group of operations you want to store in the new Macro code and decided to store the macro in a custom event, a dedicated panel to complete the event configuration, appears.

The event panel

This same panel is going to appear by double-clicking on an already created event in the Events tab or by clicking on the Information entry in Macro Resource context menu.

The panel contains the following configurations:

  • Event name: the name of the event or of the Macro Resource you are editing

  • Fail policy: the policy to be applied during macro code execution in case of error. Possible value are:
    • Stop macro: when an error occurs, the rest of the macro code is not executed.

    • Continue: when an error occurs, the rest of the macro code is executed.

  • Saved/Custom switch: it allows switching between custom event or saved event (available only from the Event panel).

  • Macro Resource: in case of saved event the Macro Resource from which the macro code is inherited.

  • Event code: the macro code executed in the event. If the event is custom, this text area is editable, while it is disabled, if the macro code is inherited from a Macro Resource.

Procedure

  1. Click the Record Macro icon in the toolbar.

  2. Perform the operations you want to record.

  3. Click the Stop recording icon in the toolbar when you have finished your operations.

  4. Select Custom Flow Event and click Save.

  5. Configure the panel by modifying the option listed above, and then click Ok to add the new event to the list.