Else If

定义在检查其他条件时,当不满足 If (if) 命令的条件时运行的命令块。

命令可用性: 本地 IBM RPA SaaS 和 IBM RPA

描述

定义在检查其他条件时,当不满足 If (if) 命令的条件时运行的命令块。

如果不满足此命令和 If (if) 命令定义的条件,请使用 Else (elseIf) 来运行命令块。

依赖关系

必须首先使用 If (if) 命令。

脚本语法

IBM RPA 的专有脚本语言的语法与其他编程语言类似。 该脚本语法在脚本文件中定义命令的语法。 您可以在 IBM RPA Studio的 脚本 方式下使用此语法。

elseIf --left(Variant) --operator(ConditionalOperators) --right(Variant) [--negate(Boolean)]

输入参数

下表显示了此命令中提供的输入参数的列表。 在表中,您可以看到在 IBM RPA Studio的脚本方式及其 Designer 方式等效标签中工作时的参数名称。

设计器方式标签 脚本方式名称 必需的 接受的变量类型 描述
左操作数 left Required Any 用于评估条件的值。
运算符 operator Required ConditionalOperators 用于评估条件的规则。 有关更多信息,请参阅 operator 参数选项
右操作数 right OperatorEqual_To, Greater_Than, Greater_Than_Equal_To, Less_Than, Less_Than_Equal_To, Contains, Ends_With, Begins_With, Matches 时必需 Any 左操作数 比较以评估条件的值。
求反 negate Optional Boolean 运算符中定义的规则求反。

operator 参数选项

对条件求值的 Operator 表达式支持以下值。

  • 开头为
  • 包含
  • 结尾为
  • 等于
  • 大于
  • 大于等于
  • 为空
  • 为 null
  • 为 Null 或为空
  • 为 true
  • 小于
  • 小于或等于
  • 匹配

示例

以下示例收集学生的平均值,如果值等于 10 ,那么屏幕上将显示一条消息,指出用户有权使用 2 个数字来参与基本薪酬。 如果学生的平均值等于 9 ,那么屏幕上将显示一条消息,说明该学生有权使用 1 号码参与抽签。 对于大于 10 的值,程序会显示一条消息,指出该值无效。 如果都不符合条件,学生就不能参加抽签。

defVar --name averageStudent --type String
inputBox --title "Student Average" --prompt "Enter Average" averageStudent=value
if --left "${averageStudent}" --operator "Equal_To" --right 10
    messageBox --title Note --text "Congratulations! You finished the semester with an average of 10, you are entitled to 2 draw numbers! Get your numbers from the office!" --icon "Information" --buttons "OK" --defaultbutton "FirstButton"
elseIf --left "${averageStudent}" --operator "Equal_To" --right 9
    messageBox --title Note --text "Congratulations! You have completed the semester with an average of 9, you are entitled to 1 draw number! Get your number from the office!" --icon "Information" --buttons "OK" --defaultbutton "FirstButton"
elseIf --left "${averageStudent}" --operator "Greater_Than" --right 10
    messageBox --title Note --text "Invalid Value" --icon "Information" --buttons "OK" --defaultbutton "FirstButton"
else
    messageBox --title Note --text "Congratulations! You have completed the semester! Unfortunately only students with an average of 9 or above can participate in the draw. Good luck next semester!" --icon "Information" --buttons "OK" --defaultbutton "FirstButton"
endIf
// If student average is 9, show you can participate with 1 draw number; if it is 10, with 2 numbers. If the average is below 9, you cannot participate in the draw.