Stop Execution

Stops the execution of a script.

Command availability: IBM RPA SaaS and IBM RPA on premises

Description

Stops the execution of a script that uses the Stop Execution (stopExecution) command. Or, if the script is being referenced by another command such as Execute Script, the command can also stop the execution of the caller script aswell.

If the command runs in an error handling subroutine, the command stops the script with failure. See Exception handling scope for more information on how to deal with errors in your script.

Script syntax

IBM RPA's proprietary script language has a syntax similar to other programming languages. The script syntax defines the command's syntax in the script file. You can work with this syntax in IBM RPA Studio's Script mode.

stopExecution [--current(Boolean)]

Input parameter

The following table displays the list of input parameters available in this command. In the table, you can see the parameter name when working in IBM RPA Studio's Script mode and its Designer mode equivalent label.

Designer mode label Script mode name Required Accepted variable types Description
Only current current Optional Boolean Enable to stop only the execution of the current script, returning the execution to the caller script. Otherwise, the command will stop the execution of all scripts in the current context.

Example

Example 1: In this example, the script runs, and then stops, not displaying the last message.

logMessage --message "Running..." --type "Info"
logMessage --message "Running..." --type "Info"
logMessage --message "Stop execution" --type "Info"
stopExecution
// The script stops now, right after the command.
logMessage --message "Script interrupted" --type "Info"
// The last message is not displayed because the script has been interrupted.

Example 2: In this example, two scripts are used. The first script calls the second script using the Execute Script command. The second script starts and is interrupted by the Stop Execution command. Now, due to the Only current parameter, the execution is returned to the first script.

First script:

logMessage --message "Running...\r\n" --type "Info"
logMessage --message "Running...\r\n" --type "Info"
executeScript --handleError  --name secondScript
logMessage --message "End." --type "Info"

Second script:

logMessage --message "Running ..." --type "Info"
logMessage --message "Stop Execution" --type "Info"
stopExecution --current
// The script stops now, right after the command.
logMessage --message "Script interrupted." --type "Info"
// The last message is not displayed because the script has been interrupted.