Please provide a way to add an action to the repeat loop start instead of a condition

+1 vote
asked Mar 30, 2017 in Closed feature request by Chris38 (220 points)

I'd like to replace the empty diamond at the start of a repeat loop with an action.

In the following example, if the "data is invalid", I just want to "prompt for data" again:

    :prompt for data;
repeat while (data is valid) is (no) not (yes)
:use data;

I looked in past questions and discovered a few things, but nothing about this particular case. It seems like it would make the diagram a little smaller.

Maybe something like repeat (prompt for data)

I can sort of do it with a while loop, but it would not look as nice.

Thank you!

1 Answer

+1 vote
answered Mar 30, 2017 by plantuml (295,000 points)
selected Mar 30, 2017 by Chris38
Best answer

Fortunately, this is a part of code we are currently working on.

So in last beta (beta14):

You can now have:

repeat :foo as starting label;
  :read data;
  :generate diagrams;
backward:This is backward;
repeat while (more data?)

This has not been tested very widely, so feedback welcome!
Thanks for your idea!

commented Mar 30, 2017 by Chris38 (220 points)

I was hoping I could have the starting label be an activity instead of a diamond (in my example, I am prompting for data until the data is valid, the start of my loop is not a test, so a round box seems more appropriate).

backward looks like a nice addition, will it be possible to have several activities in the backward "chain" (ah, so many requests! although this is more of a question really.)

commented Mar 30, 2017 by plantuml (295,000 points)
Ok, we've removed the diamond in last beta16

About backward, adding several activities in the backward chain is not too difficult to implement, so we will probably do it latter.

Welcome still welcome :-)
commented Mar 30, 2017 by Chris38 (220 points)
Impressive, thank you!!
commented Feb 6, 2020 by Cedric

Is it possible to specify a color code in the repeat and backward definitions? Parsing-wise, it seems feasible to manage:

    #AAA:Loopback activity;
    floating note left: Note for loopback activity

    :Some internal activity;

    #AFF:Backward activity 1;
    floating note right: Note for backward activity 1
    #AFF:Backward activity 2;
    floating note right: Note for backward activity 2

repeat while (Success?) is (No)

where the first activity after the start of the repeat clause and its associated note (for example) define the loopback activity.

commented Nov 28, 2023 by Artur
This repeat loop with first activites with two incoming edges will never activate according to UML specification. So this functionality may be confusing to some users. There could be model mistakes due to it.

Maybe it's important for some other notation, but for activities diagram as in UML 2.5.1 it would be wrong.