Exit

3.2.10 Exit

Exit - Terminate the script, procedure or structured block of code and return an exit code. If an exit command with the 'process' scope is called during script execution, it will terminate T-Plan Robot and return the indicated exit code to the underlying operating system. See the documentation on T-Plan Robot CLI Options and its automatic script execution examples for more information.

SYNOPSIS

exit  <exit_code_number>  [scope=<process|file|procedure|block>]  [desc=<description>]

OPTIONS

exit_code_number

- Mandatory exit code. It must be an integer. A value of zero is usually used to indicate success while non-zero values indicate an error or unexpected result or behaviour. If the command is called to terminate the whole script and there's a report file created by the Report command it will display the exit code of 0 as "passed/successful" and all other codes are presented as failures. The exit code is also passed to the underlying operating system and can be used to identify the reason for the script termination by third-party frameworks.

scope=<process|file|procedure|block>

- Controls scope of the exit command. The default value is a process which terminates the script execution. If the execution is an automated one and there are no more running automated processes, the command also terminates the JVM (Java Virtual Machine) and returns the specified exit code to the underlying operating system.

The file value terminates the currently executed file. If a script is being executed from another script using the Run command, only the called script is terminated and control is returned to the master script.

The procedure value exits from the innermost procedure. If no procedure is executed, the Exit command is ignored.

The block value exits from the innermost structured block of code, i.e. one of the if/else of for statements. If the command gets called out of any such a statement, it is ignored.

desc=<description>

- Optional description supported since v2.3. It is only used if the exit scope is not specified or is equal to the process. The command then saves the description under the _EXIT_DESC variable which is picked up and displayed by the reporting framework (such as the Enterprise Report Provider).

RETURNS

The command returns the exit code which is specified as its argument.

EXAMPLES

Exit 10

- Terminate the executed script and return 10 as the exit code.

Typeline myapplication 
Waitfor update extent=40% timeout=20s ontimeout="Exit 2"
 cumulative=true

- This is a typical usage of the Exit command. It shows a situation when you start a GUI application called myapplication from a terminal window. Let's suppose that the myapplication window has a fixed size equal to at least 40% of the screen size. If the GUI starts properly, the script will continue. The Waitfor command will otherwise wait for 20 seconds and then terminate the script with an exit code of 2.