Activity Diagram, adding SWITCH keywords

+1 vote
asked Dec 5, 2020 in Wanted features by kasra (1,000 points)

Hello,

It would be nice if we could have the SWITCH keyword or something that simulates that.

Today the best option is  ( as far as I know )

@startuml
'!pragma useVerticalIf on
start
if (condition A) then (yes)
  :Text 1;
elseif (condition B) then (yes)
  :Text 2;
elseif (condition C) then (yes)
  :Text 3;
elseif (condition D) then (yes)
  :Text 4;
endif
@enduml

here is the diagram.

How could we get rid of the last branch and directly continue from the bottom line? 

if I exchange the last "elseif" to "else"  ( and I have to remove the "then (yes)") the condition is written on the line

and we lose consistency in my opinion.

the SWITCH is useful when we have an Enumeration and we know exactly the different possible values.

Hope that I am clear.

Best Regards,

Kasra

commented Apr 28, 2021 by etienne-sf (100 points)
edited Apr 28, 2021 by etienne-sf

This other question shows another way to say that (but it's still a wish smiley) :

https://forum.plantuml.net/1041/switch-or-multiple-else-branches-for-new-activity-diagram?state=comment-2107&show=2107#c2107

Etienne

1 Answer

0 votes
answered Apr 29, 2021 by The-Lu (64,340 points)
selected Apr 29, 2021 by kasra
 
Best answer

Hello K. and all,

From ~V1.2019.5 (20 Apr, 2019), you can use:

@startuml
start
switch (test?)
case ( condition A )
  :Text 1;
case ( condition B ) 
  :Text 2;
case ( condition C )
  :Text 3;
case ( condition D )
  :Text 4;
endswitch
stop
@enduml

If that can help,
Regards,
Th.

commented Apr 29, 2021 by kasra (1,000 points)
Hello,

usually, I read the documentation but I missed this switch keyword!

Thanks a lot for your help

Regards,

Kasra
...