SELECT WHEN is used to define conditions for when groups of operation should be performed or not.
ENDSL or END is used to close a SELECT statement.
Multiple WHEN groups can be defined.
OTHER is used in combination with SELECT and WHEN to define what should be done if the previous conditions have not been met.
Example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
dcl-s Name varchar(128); dcl-s Message varchar(52); Name = 'Mats'; select; when Name = 'Mats'; Message = Name + ' is living on the Swedish East Cost'; when Name = 'Christoffer'; Message = Name + ' is living on the Swedish West Cost'; other; Message = 'I do not know where ' + Name + ' is living'; endsl; dsply Message; |
Example RPGIV Fixed Format
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
D Name 128A D Message 52A * C Eval Name = 'Mats' * C Select C When Name = 'Mats' C Eval Message = %Trim(Name) + C ' is living on the Swedish East Cost' C When Name = 'Christoffer' C Eval Message = %Trim(Name) + C ' is living on the Swedish West Cost' C Other C Eval Message = 'I do not know where ' + C %Trim(Name) + ' is living' C EndSl * C Message Dsply |