Exit
Exit 関数を使用して、ポリシー内の任意の個所で関数を停止したり、ポリシーを終了したりすることができます。
Exit 関数の動作は、IPL と JavaScript とでは異なります。
IPL では、ユーザー定義関数内で Exit を使用すると、その関数は終了しますが、ポリシーは続行します。
JavaScript では、ポリシー内のユーザー定義関数で Exit を使用すると、ポリシー全体が終了します。
JavaScript ポリシー内で関数を停止する場合は、ポリシー内で return コマンドを使用する必要があります。
構文
Exit 関数の構文は次のとおりです。
Exit()
例
この例では、X 変数の値をテストします。
X が 10 より大きい場合、ポリシーは終了します。
X が 10 より小さい場合、ポリシー・ログにメッセージが書き込まれます。
以下の例は、IPL と 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");;IPL の場合の出力
Exiting if statement
End of policyJavaScript の場合の出力
Exiting if statement以下の例は、IPL での Exit 関数の使用を示しています。
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....");以下の例は、JavaScript での Exit および return 関数の使用を示しています。
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....");