Performs a set of commands depending on the condition.
Do Case
Case condition1
CodeBlock1
Case conditionN
CodeBlockN
Otherwise
OtherwiseCodeBlock
Endcase
Where:
condition1
Condition1 evaluated.
CodeBlock1
Code block that is executed if condition1 evaluates to true.
conditionN
ConditionN evaluated.
CodeBlockN
Code block that is executed if conditionN evaluates to true.
Otherwise
Clause that establishes a final alternative, in case all previous conditions are not matched.
OtherwiseCodeBlock
Block that is executed if all previous conditions are not matched (evaluated false).
Objects: Procedure, Web Panel, Panel, Transaction
Generators: .NET, .NET Framework, Java, Angular, Android, Apple
This command works in the same way as if/else. It performs a set of commands within cases depending on conditions, which can involve attributes and/or variables.
When the first Case whose condition is satisfied is executed, it prevents the others from being executed.
The statements specified under the Otherwise clause are executed only if all Case conditions are evaluated as false.
Samples
The following code can be defined, for example, inside a GeneXus object Event or Source:
Do Case
Case &Today.Month()=1
&Discount=15
&Bonus=500
Case &Today.Month()=2
&Discount=10
&Bonus=300
Otherwise
&Discount=5
&Bonus=0
Endcase
Sub command