Need to do multiple breaks in a repeat of an activity diagram

0 votes
asked Jun 25, 2022 in Wanted features by Johnny

Hi all,

we were trying to create an activity diagram that contains a repeat loop, in which the flow can break on several certain if statements, as shown in the example below:

@startuml

start

repeat

    if (Error 1 happened?then (Yes)

        #palegreen:Handling 1;

        break

    else if (Error 2 happened?then (Yes)

        #palegreen:Handling 2;

        break

    else if (Error 3 happened?then (Yes)

        #palegreen:Handling 3;

        break

    endif

repeat while (Processing error?is (Yes) not (No)

:wow!;

stop

@enduml

But the rendering of the diagram is incorrect as only the arrow of the first if statement's break goes to the end of the loop, and the other two breaks just point to void. There could be more complicated scenarios that cannot be easily work-arounded using switch-case or other statements, so we would like to check if multiple breaks can be supported sometime in the future of PlantUML here? Thanks!

commented Jun 25, 2022 by The-Lu (63,920 points)

Hello J.,

A possible workaround is to use `goto`, (but that is currently only experimental...), as:

@startuml
start
repeat
    if (Error 1 happened?) then (Yes)
        #palegreen:Handling 1;
        label l
        break
    else if (Error 2 happened?) then (Yes)
        #palegreen:Handling 2;
        goto l
    else if (Error 3 happened?) then (Yes)
        #palegreen:Handling 3;
        label dummyspace
        goto l
    endif
repeat while (Processing error?) is (Yes) not (No)
:wow!;
stop
@enduml

See doc. here:

If that can help,
Regards.

commented Jun 29, 2022 by Johnny

Thanks, @The-Lu , for the suggestion, and it surely is a better work-around than our current one using a combined switch-case inside an if statement.

I would still wonder if such can be natively supported at all in the future in PlantUML, as I believe such can be quite common use-cases when creating activity diagrams.

I would not mind joining the community and contribute if there is any possible path, although I am not much familiar with Java.

Thanks again for your help, and I wish you a pleasant week!

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:

[Antispam2 Feature: please please wait 1 or 2 minutes (this message will disappear) before pressing the button otherwise it will fail](--------)
To avoid this verification in future, please log in or register.
...