About Expressions

An expression, in programming, is a combination of symbols that represents a value. The expression is interpreted according to the rules of the programming language and a value is returned.

The Expression Builder provides a quick and easy way to evaluate a simple BASIC expression right inside a step’s parameters. Expressions work by taking the text found between percentage signs and passing it to the BASIC expression interpreter. The result of the expression is then returned and replaces the expression (including the percentage signs) at runtime.

Many actions you might want to perform with expressions are already contained in Automated Workflow actions. However, you can use expressions to expand on the available actions. You can build expressions to resolve dynamic data at run time using functions, variables (including EFT Server variables), constants, and operators.

Example 1: simple mathematical expression

In this example, we want a Workflow to do a simple mathematical calculation and display the results in a message box.

  1. In the Designer, add the Message Box action to the Workflow.

  2. Specify %4+4% as the Message action’s "Message to display" parameter.

    Since the phrase 4+4 is surrounded in percentage signs, Automated Workflow knows that it should try to resolve this value and not display it literally. To resolve the expression, the value between the percentage signs is passed to the expression evaluator, where it is processed and the result is returned. At runtime, only the result (8) will be displayed.

Example 2: expression with variable

Expressions can also contain variables inside the expression. Taking the previous example a step further, assume we now want the Workflow to give the user the ability to enter a number he would like squared.

  1. Use the Create Variable action to create a variable, NUMTOSQUARE, which will contain the user's response to the question.

  2. Create an Input Box step to display the question What number would you like squared? and populate the NUMTOSQUARE variable with the answer.

  3. Create a Message Box step that displays the result by use of an expression multiplying the variable by itself. %NUMTOSQUARE * NUMTOSQUARE%

    The Workflow is shown below. You can copy and paste this into the Workflow Builder and press the run icon to see how it works.

<!--- Create the variable --->
<AMVARIABLE NAME="NUMTOSQUARE">1</AMVARIABLE>
<!--- Ask the user to enter a number --->
<AMINPUTBOX WINDOWTITLE="Enter a number" RESULTVARIABLE="NUMTOSQUARE">Which number would you liked squared?</AMINPUTBOX>
<!--- Perform the calculation using an inline expression --->
<AMMESSAGEBOX>%NUMTOSQUARE * NUMTOSQUARE%</AMMESSAGEBOX>

Notes

Notice that we first had to create the variable we intend to use. All variables to be passed into a scripting language, either explicitly through the use of a BASIC script step or implicitly through the use of an expression, need to be created first. You can accomplish this using the Create Variable action.

Variable names are not case sensitive in Automated Workflow.

Because each expression is passed to the scripting language engine, any command available from a common BASIC script is available to you for use in expressions in your step parameters. Refer to the Automated Workflow Technical Reference for more details on these powerful commands.