Performs a set of commands, depending on the condition.
Do Case
Case condition1
CodeBlock1
Case condition2
CodeBlock2
Case conditionN
CodeBlockN
Otherwise
OtherwiseCodeBlock
Endcase
Where:
condition1
Condition evaluated number one.
CodeBlock1
Block that is executed if the condition condition1 evaluates to true.
conditionN
Condition evaluated number one.
CodeBlockN
Block that is executed if the condition condition2 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.
Objects: Procedure, Web Panel, Panel, Transaction
Generators: .NET, .NET Framework, Java, Angular, Android, Apple
This command works in the same way if/else works. It is used to perform 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 execution.
The sentences specified under the Otherwise clause are executed only if all Case conditions evaluate 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