It is possible in GoAnywhere to define and import a set of variables that could act as global/system variables. You can import parts of a project from external XML files. This works much like the COPYBOOK feature in System i programs.
Follow the instructions below to set this up:
Create a simple XML file with all global variables that you would like to import into all/most of your projects. Place the file in a folder of your choice (preferably in the
~goanywhere/userdata/imports). For this example, let us name the file as
Global Variables.xml. Below are the contents of our
Global Variables.xml file:
Code: Select all<?xml version="1.0" encoding="UTF-8"?>
<globalVariables>
<variable name="global.system.name" value="S10BD458" />
<variable name="global.emails" value="[email protected], [email protected]" />
</globalVariables>
Basically we have two variables in this file. One that indicates the system name, and the other contains the list of email addresses to receive error notifications.
Now, we can import this file into any project and the two variables we have defined in the file will be available to the project at execution time. Below is a sample project that imports the above file and conditionally runs a task based on the system name:
Code: Select all<project name="Import Variables Demo" mainModule="Main" version="1.0">
<module name="Main">
<print if="global.system.name eq 'S10BD458'">
<![CDATA[Hello World!]]>
</print>
</module>
<import file="/linoma/goanywhere/userdata/imports/Global Variables.xml" />
</project>
As you might have noticed, we imported the
Global Variables.xml file into the project. To do this, right click on the
Project node in the Project Designer and select
Import an XML File from the context menu. During the execution of the project, the Project Compiler copies the contents of the
Global Variables.xml into the project (excluding the root element, in our case <globalVariables>). The expanded project is then executed.
Now, make a copy of the Global Variables.xml file and move it to your second system. Adjust the variable values as needed.
Not only you can import variables, but you can import other project components such as Modules and Tasks. So, it is possible to have a common E-Mail task that sends out error notifications in a separate file and import that task into several projects.
Note:
When working in the Project Designer, variables from the imported file are not displayed in the Variable Selection Drop-down. The imported file is loaded only at project's execution time. Any subsequent changes made to the imported file will be automatically reflected when the projects are executed the next time.