Reusing Logic

   

When you have come up with a useful sequence of actions, you may want to reuse it. Here are several methods, in increasing levels of sophistication.

 

Action lists

 

Let's take the example of a couple of actions used to log to an external log file with a date and time stamp. Before writing to the log with the Write Text File action, the Time variable is updated using the Get Date Time action.

 

 

ttreusing_before

 

Here, the log actions have been copied. This is not ideal, as if we improve the logic later on, we'll have to edit all those actions. Instead, create a new action list, called Log:

 

 

ttreusing_addactionlist

 

Move the actions to the new action list. Now, create a parameter to contain the log message, by right clicking on the action list title.

 

 

ttreusing_parameters

 

Replace the hard-coded message in the "Write to Text File" action. Action list parameters behave just like normal variables.

 

 

ttreusing_createtextfile

 

The action list now looks like this:

 

 

ttreusing_actionlistafter

 

The final step is to replace the original calls with Run Action List actions.

 

 

ttreusing_runactionlist

 

The result is this:

 

ttreusing_mainafter

 

External action lists

 

The next step in reusing action logic is to group these utility action lists into one project:

 

ttreusing_project

 

You can now call these action lists from any project.