terminate Function for Scripts

The terminate method allows stopping the execution of a script that is currently running.

Syntax

It is possible to stop the script execution thread. See the following syntax:

 

terminate();

 

When executing a script that includes a subscription, for example:

 

var result = subscribeValues("System1.ManagementView:ManagementView.SystemSettings.OrganizationModes.DayNight", "Value", onOrganizationModeChanged);

if (result.error) {

    console("Subscription error: {0}", result.error);

    terminate();

}

 

console("Subscription succeeded");

...

function onOrganizationModeChanged(object, values) {

    console("New value = {0}", values.value.value);

}

 

Error Handling

Errors can occur in case:

Examples of Use

 

How to stop the script execution by calling the related method with a defined variable or any string value as parameter

    terminate(100);