Else If
Defines the command block that runs when the condition of the If (if) command is not met, while checking for other conditions.
Command availability: IBM RPA SaaS and IBM RPA on premises
Description
Defines the command block that runs when the condition of the If (if) command is not met, while checking for other conditions.
Use Else (elseIf) to run a block of commands if neither the conditions defined by this command and the If (if) commands are met..
Dependencies
You must use an If (if) command first.
Script syntax
IBM RPA's proprietary script language has a syntax similar to other programming languages. The script syntax defines the command's syntax in the script file. You can work with this syntax in IBM RPA Studio's Script mode.
elseIf --left(Variant) --operator(ConditionalOperators) --right(Variant) [--negate(Boolean)]
Input parameters
The following table displays the list of input parameters available in this command. In the table, you can see the parameter name when working in IBM RPA Studio's Script mode and its Designer mode equivalent label.
| Designer mode label | Script mode name | Required | Accepted variable types | Description |
|---|---|---|---|---|
| Left Operand | left |
Required |
Any |
Value used to evaluate the condition. |
| Operator | operator |
Required |
ConditionalOperators |
Rule used to evaluate the condition. For more information, see operator parameter options. |
| Right operand | right |
Required when Operator is Equal_To, Greater_Than, Greater_Than_Equal_To, Less_Than, Less_Than_Equal_To, Contains, Ends_With, Begins_With, Matches |
Any |
Value that is compared to the Left operand to evaluate the condition. |
| Negate | negate |
Optional |
Boolean |
Negates the rule defined in Operator. |
operator parameter options
The following values are supported for the Operator expression that evaluates the condition.
- Begins with
- Contains
- Ends with
- Equal to
- Greater than
- Greater than or equal to
- Is empty
- Is null
- Is null or empty
- Is true
- Less than
- Less than or equal to
- Matches
Example
The following example collects a student's average and, if the value is equal to 10, a message appears on the screen stating that the user is entitled to 2 numbers to participate in a draw. If the student's average is equal to 9, a message appears on the screen stating that the student is entitled to 1 number to participate in a draw. For values above 10, the program displays a message stating that the value is invalid. If none of the conditions are met, the student can't participate in the draw.
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.