NOTE: This feature is only available in the registered Professional version
Inline expressions (aka embedded expressions) provide a quick and easy way to evaluate a simple AutoMate™ Basic expression right inside a step’s parameters, instead of writing an entire script. Inline expressions work by taking any unresolved variables it finds between double-exclamation points and passing them to the AutoMate™ Basic interpreter. The return value is then passed back to AutoMate™, which replaces your variable with the return value of the expression.
For example, consider the following trivial example: we want a task to do a simple mathematical calculation and display the results in a message-box. In the past, it would have been necessary to make an AutoMate™ BASIC script that carried out the calculation, and displayed the result in using BASIC’s MsgBox command. The script would then need to be called from an AutoMate™ BASIC Script step. Now, the exact same function can be done using the Message step, and using !!4+4!! as the Message step’s “Message to display” parameter. Since the phrase 4+4 does not exist as a variable name that was created inside AutoMate™, it is passed to the scripting language, where it is processed and returned.
Inline expressions can also contain AutoMate™ variables imbedded inside the expression. Taking the previous example a step further, assume we now want the task to give the user the ability to enter a number he would like squared (that is, multiplied by itself). Because AutoMate™ passes its own variable list to the scripting language before the step is evaluated, it is aware of any variables you have already used in AutoMate™. Therefore, your task could look like this (hint: you can copy and paste this into the step builder and press F5 to see how it works!):
REM: Create the variable
CREATEVAR: "NUMTOSQUARE","1"
REM: Ask the user to enter a number
INPUTTOVAR: "Enter a number","Which number would you liked squared?","NUMTOSQUARE",0
REM: Perform the calculation using an inline expression
MESSAGE: "!!NUMTOSQUARE * NUMTOSQUARE!!",1That’s it!
There are a few things here to note:
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 SCRIPT step or implicitly through the use of inline expressions, need to be declared first. You can accomplish this using the Create Variable action .
Notice that when we are using the AutoMate™ variables in the string to be evaluated that we did not enclose them in the AutoMate™ variable format (i.e. enclosing the variable name between double exclamation points). This is because once the string is passed to the scripting language, they become scripting variables, and not AutoMate™ variables. Variable names are not case sensitive in the AutoMate™ BASIC language; the variables are capitalized here for clarity.
Because each expression is passed to the scripting language engine, any command available from a common AutoMate™ BASIC script is available to you through inline functions. Refer to the AutoMate™ BASIC Language Reference for more details on these powerful commands.
Related Topics: