Welcome to PlantUML Q&A, where you can ask questions and receive answers from other members of the community.

You can also submit new features request and vote for them.

Repeat loop starting with action instead of condition

0 votes

is it possible 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!
asked Mar 30 by Chris38 (390 points)

1 Answer

+1 vote
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!

answered Mar 30 by plantuml (126,850 points)
selected Mar 30 by Chris38

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.)

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 :-)
Impressive, thank you!!
Support This Project Offer 250 Mo! Follow PlantUML on Twitter