Script mode
The Script development view allows you to use the IBM Robotic Process Automation scripting language. IBM RPA scripting language is a procedural programming language to build scripts.
The syntax
The syntax is composed of commands and its parameters. Each line in an script runs an action defined by a command. You can only have one command per line.
commandVerb --inputparameter {"<enum_value>"|"${variable}"|"<value>"} <output_variable>=outputparameter
where:
-
commandVerb
Command's verb in the IBM RPA scripting language syntax. In the Designer development view of IBM RPA Studio, you see the command's label. -
--inputparameter
One possible input parameter for the command. Commands can have required or optional input parameters, or both. These parameters set initial values for the command's operation and can toggle configuration settings for the command.
Depending on the input parameter, you can set predefined values such as in<enum_value>
, or pass in the value from a variable like in${variable}
, or use a string literal as in<value>
or possibly"my value"
. -
<output_variable>=outputparameter
The syntax for storing the return value of one possible output parameter for the command in a variable. Output parameters are always optional, although the script's logic can force you to use them. These parameters can contain values returned from the command's operation.
If you don't use output parameters, you can't get the value returned from the command's operation. To get these values, you need to set the variable name that is going to store this value, as in<output_variable>
. In this context, if the variable<output_variable>
does not exist, you need to create it if you are using the Script view of IBM RPA Studio.
IBM RPA scripting language also allows you add comments to your code. For inline comments, use two slashes (//
) in the syntax. For example:
// This is a comment.
commandVerb --inputparameter "<value>" <output_variable>=outputparameter
For a command comment, use the --comment
input parameter. For example:
commandVerb --inputparameter "<value>" --comment "This is a comment"
The hierarchy
There is a hierarchy to enter commands into your script. You need to import assets at the top of the script. If you don't use assets, the variables must be at the top.
Subroutines and business rules are located at the end of the script. Despite this, you can use other commands to call them in a specific line of your script.
Components of your script, like control flow commands, subroutines, and business rules set, must follow the correct indentation. The IBM RPA Studio identifies when you use these components and automatically indents the lines.
Example:
// The asset import goes here.
// The variable definition goes here.
if --left "<value>" --operator "<enum_value>" --right "<value>"
// Enter other commands here.
else
// Enter other commands here.
endIf
Syntax errors might occur when mistakes related to indentation, variables with wrong types, links to variables, subroutines, business rules, or invalid assets are found, for example. The parser raises these errors when you change to the Designer development view.
The hints for developing
Use the shortcuts when developing in Script development view:
Ctrl+Backspace
orBackspace
: To suggestions about the following commands and their parameters.Tab
: To enter a chosen command, parameter, or value in the command line.Alt+Shift+V
: To create variables.Alt+Shift+R
: To create subroutines.Alt+Shift+S
: To create business rules.