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 返回并继续运行主脚本。当子脚本运行时,它将一个值存储在 ReturnValue 操作的 Return 属性中,然后将该值传递回主脚本的 ReturnVariable 中的 Runsub 属性。

如果您有一个或多个较大的脚本想要分解为较小的脚本,那么这个操作尤其有用。

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.

通用

电子邮件 聊天 电话 语音信箱 工作项目 短信 数字

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?