Multiple modules conditionally executed per variable value
Posted: Mon Apr 06, 2009 10:47 am
In GoAnywhere you can specify multiple modules in a project. Some of these modules could be used for error processing while others can be used for organizing tasks. In the example below I have specified a project level variable called FirstOrSecond. If that variable is set to a 1 the "First" module will execute. If it is set to a 2 the "Second" module will execute.
When GoAnywhere executes this project by default it will begin with the Main module. On the Main module I've added a couple modules to the Depends On attribute which are separated by a comma. Since the Main module depends on First and Second to run it will then pass control to the First module. I added a Execute Only If condition on that module to say to run only when the variable is set to a 1. I've also added conditional logic to the Second module to run only if it's a 2.
In the example below the "First" module will execute because the variable is set to a 1. The "Second" module will be skipped and then the "Main" module will finish execution. For demonstration purposes each module only prints some static text.
When GoAnywhere executes this project by default it will begin with the Main module. On the Main module I've added a couple modules to the Depends On attribute which are separated by a comma. Since the Main module depends on First and Second to run it will then pass control to the First module. I added a Execute Only If condition on that module to say to run only when the variable is set to a 1. I've also added conditional logic to the Second module to run only if it's a 2.
In the example below the "First" module will execute because the variable is set to a 1. The "Second" module will be skipped and then the "Main" module will finish execution. For demonstration purposes each module only prints some static text.
Code: Select all
With this in place I can easily override the project variable at run time (via GoAnywhere's scheduler, Execute Advanced screen, RUNPROJECT command, etc) and determine what tasks will be executed.<project name="Multiple Modules" mainModule="Main" version="1.0">
<description></description>
<module name="Main" dependsOn="First,Second">
<print>
<![CDATA[Main module printing]]>
</print>
</module>
<module name="First" if="FirstOrSecond eq 1">
<print>
<![CDATA[First half printing]]>
</print>
</module>
<module name="Second" if="FirstOrSecond eq 2">
<print>
<![CDATA[Second half printing]]>
</print>
</module>
<variable name="FirstOrSecond" value="1" />
</project>