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.

Activity: Add action on the return arrow of a repeat

+1 vote

Hello,

First of all, plantUML is an impressive tool. Thank you so much for making UML diagrams so easy to create :)!!

My question : Basically, I want to implement this kind of structure:

 

 

 

 

 

 

 

 

 

 

Today what I do is:

@startuml
start
repeat
  :Test something;
    if (Something went wrong?) then (yes)
      :Alert "Error";
    else
      ->no;
    endif

repeat while (Something went wrong?) is (yes)
->no;
stop
@enduml

 

Is it something that is possible?

 

Thank you for your help.

 

asked Nov 30, 2016 in Wanted features by anonymous
edited Nov 30, 2016
Hi!

I really would like to have this feature, too.
It is not really solved by a "goto" or "break".
It would be great to be a able to place actions is the "backward branch" of a loop.

Maybe a syntax like this:

repeat
:ForwardActivity;
repeat backward while ( )
:BackwardActivity;
end backward

Otherwise one needs to check the same condition several times and it looks ugly.

Generally, it would be great to stear the growths of the diagram in certain directions like it is possible for state diagrams.

Thanks for all your effort anyway.

BR

8 Answers

+1 vote

The ability to break loop is a very asked feature.
(See all requests about goto!)

Fortunatly, we figure out a way to implement "break" in repeat loop, as it was slightly easier to do than full goto.
So with last beta https://dl.dropboxusercontent.com/u/13064071/plantuml.jar
you use the new "break" keyword, that has the same meaning as in Java/C/C#/C++

For example:

@startuml
repeat
:test something;
if (something get wrong) then (no)
break
endif
:error;
repeat while
:some more;
@enduml


This is really an alpha version: it will probably not work in many cases.
So we need some testers here: thanks to report bugs here.

If we succeed in making this working with repeat loop, we will extend it to other loops, and possibly add "continue" feature.
 

answered Dec 6, 2016 by plantuml (126,850 points)
0 votes

Thanks a lot for the update.
I just tried the new version and I got this:

 

It is very nice :)!! Thanks again.

And here is a first feedback : it's not my need but I tried to put a break in the else clause and it broke:

@startuml
repeat
  :Test something;
    if (Something went wrong?) then (yes)
      :Alert "Error";
    else
      break
    endif
repeat while (Something went wrong?) is (yes)
->no;
:Alert "Sucess";
@enduml

An error has occured : java.lang.UnsupportedOperationException: class net.sourceforge.plantuml.activitydiagram3.ftile.vcompact.cond.FtileIfWithLinks

Hope this helps!

Regards

answered Dec 6, 2016 by Missan (360 points)
Yes, it helps!
Here is a new beta that partially solved this https://dl.dropboxusercontent.com/u/13064071/plantuml.jar

However, the "break" link is now crossing other elements : this is where the real difficulties start... We have to think about all this.

Thanks again
0 votes

Here is the result of a break from an else with the new beta version:

 

There is indeed still a bit of work to make it a usable feature. But there is a workaround (put the break in the if section).
Thanks again for making an effort on this feature :)!!
 

answered Dec 7, 2016 by Missan (360 points)
0 votes

I just found 3 regressions (one major and two minor) :

1/ It impossible to add note almost everywhere close to the repeat:

@startuml
start
repeat
 ### It won't work from here...
  note left : A note
  :Test something;
    if (Something went wrong?) then (no)
      :OK;
      break
    endif
    :Alert "Error";
repeat while (Something went wrong?) is (yes)
->no;
:Alert "Sucess";
 ### ... To here
stop
@enduml

2/ There is no padding if there is long text in a step:

@startuml
start
repeat
  :Test something;
    if (Something went wrong?) then (no)
      :OK;
      break
    endif
    :Alert "Error with long text";
repeat while (Something went wrong?) is (yes)
->no;
:Alert "Sucess";
stop
@enduml

OR

@startuml
start
repeat
  :Test something;
    if (Something went wrong?) then (no)
      :OK;
      break
    endif
    :Alert "Error";
repeat while (Something went wrong with long text?) is (yes)
->no;
:Alert "Sucess";
stop
@enduml

3/ There is an issue with arrows. You can get up to 3 arrow on the same line if add a label to the line:

@startuml
start
repeat
  :Test something;
    if (Something went wrong?) then (no)
      :OK;
      break
    endif
    ->NOK;
    :Alert "Error with long text";
repeat while (Something went wrong with long text?) is (yes)
->no;
:Alert "Sucess";
stop
@enduml

Around the "NOK"

Hope this helps!

answered Dec 7, 2016 by Missan (360 points)
It helps!
First point is solved in last beta https://dl.dropboxusercontent.com/u/13064071/plantuml.jar
We're still working on others.
Thanks
0 votes

Thanks for the update.

1/ Comments

I think it is partially working. This piece of code produces a strange result:

@startuml
start
repeat
  floating note left : A note
  :Test something;
    if (Something went wrong?) then (no)
      :OK;
      break
    endif
    ->NOK;
    :Alert "Error with long text";
repeat while (Something went wrong with long text?) is (yes)
->no;
:Alert "Sucess";
stop
@enduml

 

More over is still buggy in the following locations:

@startuml
start
repeat
  :Test something;
  ### Buggy from here...
  floating note left : A note
    if (Something went wrong?) then (no)
      :OK;
      break
    endif
    ->NOK;
    :Alert "Error with long text";
repeat while (Something went wrong with long text?) is (yes)
->no;
### ... to here
:Alert "Sucess";
stop
@enduml

An error has occured : java.lang.UnsupportedOperationException: class net.sourceforge.plantuml.activitydiagram3.ftile.vcompact.FtileWithNoteOpale

Good luck :)!

answered Dec 7, 2016 by Missan (360 points)
OK, here is a new beta
https://dl.dropboxusercontent.com/u/13064071/plantuml.jar
Right now, we are focusing on crash / strange drawing.
We'll work on "padding" issue later, when/if everything will be working.
So do not hesitate to post new examples, it really helps : we do not have time to test our code :-)
We have fixed the padding issue in last beta https://dl.dropboxusercontent.com/u/13064071/plantuml.jar
0 votes

Here are the results regarding the padding issue:

It works in simple cases :)!!

 

 

 

Nice work!
Thanks again for the developpement of such a great tool :)!!

answered Dec 16, 2016 by Missan (360 points)
+1 vote

It took us a very long time, but since this is a very asked feature, we give it a chance.

With last beta https://www.dropbox.com/s/koo42q3d9gxw288/plantuml.jar?dl=0

You can have now:

@startuml

start

repeat
  :read data;
  :generate diagrams;
backward:This is backward;
repeat while (more data?)

stop

@enduml

This is a first version : the "backward" stuff can only be on one line.

Very few tests have been done, so feedback is welcome!

In future, we may accept several "backward" activify, but we will never be able to add complex structures (like if, while...) in the backward itself.

 

answered Mar 29 by plantuml (126,850 points)
0 votes

Hello,

 

I just tested last version and it works like a charm with the given example.

 

Thanks a lot for the update.

I'll try to add comments and stuff like that when I'll have time.

 

Thanks!

answered Mar 31 by Missan (360 points)
Support This Project Offer 250 Mo! Follow PlantUML on Twitter
...