Runsub

The Runsub action icon, a curled piece of paper with two arrows pointing to the right next to it at the top and bottom.

調用下標,下標運行後使用 Return action 返回並繼續運行主指令碼。當子執行碼執行時,它會將值儲存在 Return 動作的 ReturnValue 屬性中,然後將該值傳遞回主要指令碼的 Runsub 動作中的 ReturnVariable 屬性。

若您有一個或多個較大的指令碼,而您希望將其分解為較小的指令碼,則此動作尤其有用。

Dependencies

  • 主要指令碼和子指令碼必須位在同一資料夾中。

  • 主指令碼類型和子指令碼類型必須相同。例如,如果主指令碼為電話指令碼,則子指令碼也必須為電話指令碼。
  • 若在主要指令碼中放置一個 Runsub 動作,則子指令碼必須有一個 Return 動作。
  • Runsub 可將多個變數從主要指令碼傳遞給子指令碼,但子指令碼只能向主要指令碼返回一個值(在 ReturnVariable 屬性中)。
  • 當子指令碼終止時,子指令碼中定義的任何變數將不再可用。
  • RunScript SpawnRunsub 或類似指令碼調用的所有指令碼必須有效並活躍。在儲存過程中,Studio會驗證所有由動作調用的指令碼。如果其中任何一個無效或非活躍,Studio將顯示一個錯誤並無法儲存。

Supported Script Types

The icon for a Generic script type - a rectangle with < and > symbols inside it.

The icon for the Email script type - a large @ symbol in a diamond.

The icon for the Chat script type - a chat bubble with an ellipsis inside (...), in a diamond shape.

The icon for the Phone script type - an old-style phone handset with curved lines indicating sound coming out of it.

The icon for the Voicemail script type - a symbol that looks like a cassette tape - two circles sitting on a horizontal line.

The icon for the Work Item script type-a piece of paper with one corner folded down and a bullet list on it.

The icon for the SMS script type - a smart phone with a chat bubble coming out of it.

The icon for the Digital script type - a computer monitor with a smartphone next to it.

一般

電郵 聊天 電話 語音郵件 工作項目 SMS 數位

Comparison of Similar Actions

以下動作有類似的功能,但有一些關鍵區別:

  • Runscript:當 Runscript 觸發子指令碼時,將無法從該子指令碼返回到第一個指令碼。
  • Runsub:當 Runsub 觸發子指令碼時,該指令碼可返回第一個指令碼,只要子指令碼擁有 Return 動作。該子指令碼完成後,Return 動作將向 Runsub 動作傳回一個值。

Input Properties

這些屬性定義了動作執行時使用的資料。

屬性

描述

標題

輸入在指令碼中唯一標識此操作的短語。標題出現在指令碼畫布上的動作圖示下。The default is the action name.

ScriptName

您想要建置的指令碼。您可以點擊動作屬性方塊頂部的 Choose Script 連結,選擇為您的業務單元儲存的指令碼。

ReturnVariable

將返回到主要指令碼的值儲存在此屬性中。若要傳遞多個值,請使用陣列作為變數。
Parameters

點擊欄位中的省略號圖示,並為要傳遞給此新增一個變數,以便傳送到所產生的指令碼。在編輯器視窗中的每行輸入一個變數。使用有意義的變數名稱。變數名稱不一定要和產生的指令碼中使用的相應變數的名稱一致

傳入指令碼的參數會傳遞到出現在該指令碼的Begin動作的追蹤輸出中。

結果分支條件

結果分支條件允許您在指令碼中建立分支,以處理執行動作時的不同結果。

條件

描述

Default

指令碼未能滿足需要它採用其中一個分支的條件時採用的路徑。如果沒有定義動作的其他分支,也會採用該路徑。

OnError

動作未能正確執行時採用的路徑。例如,當出現連接不良、語法錯誤等意外問題時。_ERR變數(帶有一個下畫線字元)應填入針對問題的簡要說明。

Script Example

此範例不是一個完整的指令碼。使用此動作時需要額外的指令碼編寫工作。

In the main script below (shown top), when the script is triggered, the Runsub action immediately triggers the subscript (shown bottom). In the subscript, Voiceparams sets the Text-to-Speech settings, and the Hours action sets branches for open, closed, and holiday to three different Return actions. When the subscript is finished, the values in the ReturnValues property (in the Return action) are stored in the ReturnVariable field (Runsub action in the main script). The Case action then sets the open, closed, and holiday branches as appropriate.

Main Script

An example script, showing Studio actions with arrows connecting them. Each action has a label beneath it to indicate what the action does in the script.

Would you like to download this script?

Subscript

An example script, showing Studio actions with arrows connecting them. Each action has a label beneath it to indicate what the action does in the script.

The three Return actions provide values in the ReturnValue property so the Case action in the main script can determine which branch to follow.

Would you like to download this script?