Arrow description for while loop

0 votes
asked Oct 6, 2020 in Wanted features by wro02922 (780 points)

This topic is continuation of https://forum.plantuml.net/12180/unable-to-add-arrow-text-description-after-backward-keyword.
I would like to ask you to add arrow description to object 'data available?'. The description back to the 'data available?' action can be executed as for elsif, i.e. (incoming description) elseif (condition) else (outgoing description).

P.S.
Could you check why dsc_5 ovrrides dsc_4?

@startuml
start
->dsc_1;
(incoming description from backward) while (data available?)
  ->dsc_2;
  :read data;
  ->dsc_3;
  :generate diagrams;
  ->dsc_4;
backward :Warning; 
->dsc_5;
endwhile
stop
@enduml

1 Answer

0 votes
answered Oct 12, 2020 by plantuml (295,800 points)

We are still looking for a clear syntax.

With last official release, you have to use:

@startuml
start
->dsc_1;
while (data available?)
  ->dsc_2;
  :read data;
  ->dsc_3;
  :generate diagrams;
  (->dsc_4) backward :Warning; (->dsc_5)
endwhile
->dsc_6;
:eof;
@enduml

What do you think about this one ?

commented Oct 14, 2020 by wro02922 (780 points)

I think that the '->' should be omitted to be consistent with the previously introduced syntax for (incoming description)elseif.

(->dsc_4) backward :Warning; (->dsc_5)

It seems that with the current implementation the while and repeat loops have different behavior / draw, i.e. without the backward keyword both loops are consistent, i.e. the intermediate arrow is present in the reverse direction.

 imageimage

If I use the backward keyword, I notice a different behavior, i.e. the repeat loop will draw an intermediate arrow after the object specified after the backward keyword while the while loop will not do that. So, the open question is whether this arrow should appear after the word backward or not. I suggest that it should not appear in both cases.

http://www.plantuml.com/plantuml/uml/TT31QWCX40RW-pp5Vuo7tDeU598yHEzbiautKbU3kjtNhoiAtKD0P9XVd8-vvSAfh8kdLX1j3-S59yk5mR_iFD-zN1K1EWbRx86XyyNcwUlDxErPWYGk0kjuJhpa4RyREfqlBamATvv-DauMkjx1XTcWHd4jgh_zC2J1jk5KAV590vJaALoWlsC4PxHk_G0L9juSNAyvE7e6Hty-N4Oze_6VXUxgWBwO9IPfmwwgGsyLlYzm57y0

PlantUML diagram

@startuml
start

while (data available?)
  :read data;
->dsc_4;
  :generate diagrams;
->dsc_5;
(->inc) backward :warning; (->out)
->dsc_6;
endwhile

stop

start

repeat :foo as starting label;
  :read data;
  :generate diagrams;
-> dsc_5;
(->inc)backward:This is backward; (->out)
-> dsc_6;
repeat while (more data?)

stop
@enduml

Note that for the current implementation the '-> dsc_5' and '-> dsc_6' for the while loop and '-> dsc_6' for the repeat loop are not visible, and the compiler does not trigger any warning or error.

commented Oct 14, 2020 by The-Lu (74,900 points)

Hello all,

'->' omitted or not;
Another question/wanted feature, in order to debate :

  • How to change the style (color, style) of the backward's arrows?

Hint/like:

-[#blue]->
'or
-[#green,dashed]->

Regards,
Th.

commented Oct 14, 2020 by plantuml (295,800 points)

@wro02922

Last beta http://beta.plantuml.net/plantuml.jar takes some of your comment into account. (See here)

About '-> dsc_5' and '-> dsc_6' we should indeed trigger an error, this will be done in some future.

@The-Lu

Well, this is a good point. Maybe we should allow -> to be optional in backward, so that you can have, at user choice :

  • (inc) backward:This is backward; (out)
  • (->inc) backward:This is backward; (->out)
  • (-[#blue]->inc) backward:This is backward; (-[#green,dashed]->out)
What do you think about it ?
commented Oct 15, 2020 by wro02922 (780 points)
The optional arrows seem a very tempting proposition, besides, this language syntax seems to be consistent.
commented Oct 15, 2020 by The-Lu (74,900 points)
Hello,

It's perfect like that everyone is happy there, from the optional arrows, to the definition of the style by explicitly adding the arrows...
And that is also consistent, with the general rule of PlantUML.

Thanks for yours support,
Regards,
Th.
commented Oct 16, 2020 by wro02922 (780 points)

It would be good to have the same approach everywhere. Will this change be applied to repeat loop and elseif?

commented Oct 19, 2020 by plantuml (295,800 points)

Sure !

It's implemented in last beta http://beta.plantuml.net/plantuml.jar

And on the online server.

Please tell us if you find issues !

Thanks.

commented Oct 19, 2020 by wro02922 (780 points)

A minor problem arises if ';' is omitted from the description of the arrow.

@startuml
start
repeat :Enter data;
:Submit;
-[#blue]-> dsc_5
(-[#red]-> aaa) backward :Warning;
note right: Note
repeat while (Valid?) is (No) not (Yes)
stop

start
repeat :Enter data;
:Submit;
-[#blue]-> dsc_5;
(-[#red]-> aaa) backward :Warning;
note right: Note
repeat while (Valid?) is (No) not (Yes)
stop
@enduml

PlantUML diagram

 

commented Oct 19, 2020 by The-Lu (74,900 points)

Hello PlantUML,

Here is a collateral question or an observed question, not link directly by this improvement:

  • How to color the arrow after the "BB" box?
    it is good after the "CC" box: if there is another action after the box (like 'end'), but for the other...
Thanks for your support,
Regards,
Th.
commented Oct 20, 2020 by plantuml (295,800 points)
Thanks for the report !

This issue has just been fixed in last beta http://beta.plantuml.net/plantuml.jar and in the online server.

Tell us if it's not working for you.

Regards,
commented Oct 20, 2020 by The-Lu (74,900 points)

Hello PlantUML,

The issue of wro02922 with ";" or without ";" seems to be always occur.

@startuml
start
repeat :Enter data;
:Submit;
-[#blue]-> dsc_5
(-[#red]-> aaa) backward :Warning;
note right: Note
repeat while (Valid?) is (No) not (Yes)
stop

start
repeat :Enter data;
:Submit;
-[#blue]-> dsc_5;
(-[#red]-> aaa) backward :Warning;
note right: Note
repeat while (Valid?) is (No) not (Yes)
stop
@enduml

Regards,
Th.

commented Oct 20, 2020 by The-Lu (74,900 points)

Hello all,

In fact, if we add texts to arrow: the ';' is mandatory [-> label;]
And without label, we can omit the ';' [-[#blue]->]
Unless with backward where '(...)' replace ';'. wink

Regards,
Th.

...