How to label elseif arrow?

0 votes
asked Dec 8, 2021 in Question / help by anonymous
How do I label the arrow(s) that match the elseif clause? In the example below, "yes" is shown in edges for when the condition is true. I would like to print a "no" for the other edge (leading to the next condition to be checked). I tried many things, but couldn't get anything to work.

@startuml
start
if (condition A?) is (yes) then
  :Text 1;
elseif (condition B) then (yes)
  :Text 2;
  stop
elseif (condition C) then (yes)
  :Text 3;
elseif (condition D) then (yes)
  :Text 4;
else (nothing)
  :Text else;
endif
stop
@enduml

1 Answer

0 votes
answered Dec 8, 2021 by plantuml (265,020 points)
 
Best answer

We have to update the doc:

@startuml
start
if (condition A?) is (yes) then
  :Text 1;
(no) elseif (condition B) then (yes)
  :Text 2;
  stop
(no) elseif (condition C) then (yes)
  :Text 3;
(no) elseif (condition D) then (yes)
  :Text 4;
else (nothing)
  :Text else;
endif
stop
@enduml


commented Dec 9, 2021 by Kaanchan
That works. How would I then label the edge/arrow from "Text 2" to the "stop"?

The following doesn't work:

@startuml
start
if (condition A?) is (yes) then
  :Text 1;
(no) elseif (condition B) then (yes)
  :Text 2;
  (gameover)
  stop
(no) elseif (condition C) then (yes)
  :Text 3;
(no) elseif (condition D) then (yes)
  :Text 4;
else (nothing)
  :Text else;
endif
stop
@enduml
commented Dec 9, 2021 by anonymous

I imagine the language/syntax is not trivial to update, but would it be possible in future versions to parse according to natural language to achieve the same :

@startuml
start
if (condition A?) is (yes) then
  :Text 1;
elseif (condition B) is (no) then (yes)
  :Text 2;
  stop
commented Dec 9, 2021 by plantuml (265,020 points)

You can have this

@startuml
start
if (condition A?) is (yes) then
  :Text 1;
(no) elseif (condition B) then (yes)
  :Text 2;
  -> dummy;
  stop
(no) elseif (condition C) then (yes)
  :Text 3;
(no) elseif (condition D) then (yes)
  :Text 4;
else (nothing)
  :Text else;
endif
stop
@enduml

commented Dec 9, 2021 by plantuml (265,020 points)

I imagine the language/syntax is not trivial to update,
but would it be possible in future versions to parse according to natural language to achieve the same :

The language/syntax can easily be changed.
The real challenge is to find a natural syntax :-)

What about ?

 
@startuml
start
if (condition A?) is (yes) then
  :Text 1;
else (no) if (condition B) is (yes) then
  :Text 2;
  stop

Does it sound good ?

...