Using data and variables in Warewolf is easy. We have designed Warewolf to be as simple and easy to use as possible, and no simpler (thanks for that, Einstein).
To achieve this, we made Warewolf take care of data typing (integers, strings, dates etc.) for you. You don’t need to describe the data you are going to use; you just go ahead and use it. Warewolf categorizes your variable types in the background for performance gains and optimizations.
This allows you to use variables on the fly as you program your service simply by using the variable notation: two open square braces [[alphanumeric variable name followed by two closing square braces]] resulting in something that looks like this: [[MyVar]]
So how do you work with data and variables in Warewolf?
There are four easy ways to get data into your variables.
Firstly by assigning data using the Assign tool:
- Drag an Assign tool onto the design surface from the toolbox and connect it at the step you want the variable to be set:
- In the left hand field Enter [[MyVar]] and in the right hand field enter 123. This will assign the variable MyVar = 123:
- Most input or value fields (like the right hand field) can take a combination of data AND variables. The value of [[FullName]] below will be Simpson, Bart:
The second way of getting data into variables is to use a variable in the Result field of a tool:
- Drag a tool onto the design surface and connect it at the step you want the tool to execute at. We will use the Write File Tool:
- Put in the File Name and the Contents you want written to the file. Put the name of the variable that you want the Result data to go into. In this case [[DailyReportWriteSuccess]] (Double Click the body of the tool for its large view):
- The value of [[DailyReportWriteSuccess]] = Success
The third way of getting data into a variable is to pass it in as an input to the service:
- Drag the tool on that needs to use the input value and configure it as if the data was there: EXAMPLE: A calculate tool using a variable [[Num]] multiplied by itself and putting the product into a new variable [[NumSquared]]
- In the Variable window, set the Num variable to an Input by checking the Input box:
- When this service is executed on its URL, pass the value of Num in the query string:
The fourth way to get data into a variable is to output it from another service or connector:
- Drag the Hello World service from the Explorer onto a new design surface:
- The Hello World workflow has Message defined as an Output. When you drop services and connectors on the design surface they automatically create variable names for their input and output, but you can change them to anything you want/anything relevant.
- The value of [[Greeting]] = Hello Barney.
It’s as simple as that. You can read more about variables in the knowledge base.