Exit

You use the Exit function to stop a function anywhere in a policy or to exit a policy.

The Exit function works differently in IPL and JavaScript. In IPL, when you use Exit in a user-defined function it exits that function, and the policy continues. In JavaScript, when you use Exit in a user-defined function in a policy it exits the entire policy. If you want to stop a function in a JavaScript policy you must use the return command in the policy.

Syntax

The Exit function has the following syntax:

Exit()

Examples

In this example, the value of the X variable is tested. If X is greater than ten, the policy terminates. If X is less than ten, it prints a message to the policy log. The following example is valid for IPL and JavaScript.

function testX() {
X = 15;
if (X > 10) {
Log("Exiting if statement");
Exit();
} else {
Log("X is less than 10.");
}
}

testX();
Log("End of policy");;
Output for IPL
Exiting if statement
End of policy
Output for JavaScript
Exiting if statement

The following example shows the use of the Exit function in IPL:

Log("Entering Policy TestExit...");
SetGlobalVar("exitFunction","false");
SetGlobalVar("exitPolicy","false");

function testExit(test){
   SetGlobalVar("exitPolicy",test);
   if (test = true){
      Log("Exiting function TestExit....");
      Exit();
   }else{
      Log("Staying in the Policy TestExit....");
   }
}

//Passing true will exit the function testExit and exit the policy
//on the second call(below)to Exit.
//Passing false will allow the function and policy to finish to the end.
testExit(false);
if(""+(GetGlobalVar("exitPolicy")) = "true"){
   log("Exiting policy...");
   Exit();
}
Log("If you see this message, the policy continued to the end....");

The following example shows the use of the Exit and return functions in JavaScript:

Log("Entering Policy TestExit...");
SetGlobalVar("exitFunction","false");
SetGlobalVar("exitPolicy","false");

function testExit(test){
   SetGlobalVar("exitPolicy",test);
   if (test == true){
      Log("Exiting function TestExit AND policy...");
      Exit();
   }else{
      Log("Staying in the Policy TestExit....");
      return;
      Log("I will not see this log statement as we have already returned");
   }
}

//Passing true will immediately exit the function testExit AND the policy.
//Passing false will allow the function and policy to finish to the end.
testExit(true);

Log("If you see this message, the policy continued to the end....");