Deluge 文 > 制御フロー > 条件文(条件付き実行) - If, else if, else
解説
Deluge スクリプトでの「If」 構成は、他のプログラム言語と同様です。
論理型(boolean)式の値の条件によって、文の一式が実行されます。
構文
if(<if-boolean-expression>) { <if statements> } else if(<elseif-boolean-expression-1>) { <elseif statements-1> } else if(<elseif-boolean-expression-2>) { <elseif statements-2> } .. .. .. .. else if(<elseif-boolean-expression-n>) { <elseif statements-n> } else { <else statements> }
|
If 構成は、下記のルールに従います。:
<If 構成> は、スクリプト実行中に引き起こされます。<if-論理式> によって指定した条件は、評価されます。
条件が合えば、<if 文>
ブロック内の文が実行されます。条件が合わない場合には、プログラムフローは <if 文> ブロック内の文をスキップし、else や else if というキーワードを検索します。
else if 部分が引き起こされた時、<論理式-x>
によって指定された条件は評価され、条件が「true」と評価された場合には、<elseif 文-x> ブロック内の文が実行されます。
<if 条件> と、全ての <else if 条件> が失敗したときには、<else> の存在が検索され、<else 文> ブロック内の文が実行されます。
使用例① - フリー スクリプトを利用する場合
リクルートアプリケーション
をサンプルとしてご紹介します。
New_Applicant フォームの完了時(on success)ボックスの Deluge コードは、次のようになっています。:
on success { opening = New_Opening [Position_Name == this.Applied_For]; if (opening.Status == "Closed") { sendmail [ To : this.Email_ID, "suganya@adventnet.com" Subject : "Reg application for job posted at recruitment.zohocreator.com" Message : "The job profile " + this.Applied_For + "for which you have applied is not currently open " ] }
else if (opening.Experience == this.Experience) { sendmail [ To : "suganya@advetnet.com" Subject : "Applicants resume matches job profile" Message : this.Applicant_Name + " matches the job profile <br> Contact Info: " + this.Email_ID ] } else { sendmail [ To : this.Email_ID, "suganya@adventnet.com" Subject : "Reg application for job posted at recruitment.zohocreator.com" Message : "The experience required for the job profile " + this.Applied_For + "does not match yours" ] } }
|
コードの解説:
-
完了時(on success)ブロックでは、 まず、New_Opening フォームから、応募した職位に一致した Position_Name レコードを取得します。whose Position_Name matches with the
position applied for.
-
もし、職位のステータスが"Closed" の場合には、if ブロック内の文が実行されます。
-
もし、職位に求められる経験が、入力した経験と同じである場合には、else if ブロック内の文が実行されます。
-
上記の2つの条件が合わない場合には、else ブロック内の文が実行されます。
完全なサンプルを表示する
使用例② - スクリプトビルダーを利用する場合
Deluge 文 > 制御フロー > 送信の中止(Cancel Submit) をご参照ください。If 構文、, アラート(Alert), 送信の中止(Chancel submit)などの変数のアクションスクリプトを作成します。.