3

Given the following PlantUML code:

@startuml

start

repeat
    :Task 1;

    if (Condition 1) then (Yes)
        :Task 2;
        
    else (No)
        :Continue Loop;
    endif


    if (Condition 2) then (Yes)
        :Task 3;
        
    else (No)
        :Continue Loop;
    endif
    
repeat while (More Data?) is (Yes) not (No)

end
@enduml

What I want is to have a loop continue where there is currently a task called Continue Loop. I can't see how this is possible.

Can someone please tell me what the syntax is for doing this?

millie
  • 2,642
  • 10
  • 39
  • 58

2 Answers2

3

What I want is to have a loop continue where there is currently a task called Continue Loop. I can't see how this is possible.

As Axel Kemper points out in his answer, there is no continue statement.

Like Axel, I refactored your if/then logic to nest the second condition inside the true result of the first condition. This makes it so that the continue instructions essentially fall through (false conditions) to the bottom of the loop. It's a solution to the example you gave, but it might not work for all cases of where you'd want to use a continue, like in Python or other languages:

@startuml

start

repeat
    :Task 1;

    if (Condition 1) then (Yes)
        :Task 2;

        if (Condition 2) then (Yes)
            :Task 3;
        else (No)
            ' :Continue Loop;
        endif        

    else (No)
        ' :Continue Loop;
    endif

repeat while (More Data?) is (Yes) not (No)

stop
@enduml

enter image description here

Fuhrmanator
  • 11,459
  • 6
  • 62
  • 111
0

According to the PlantUML Reference Guide, no special continue command is available.
But there is a backward statement:

@startuml

start

repeat
    :Task 1;

    if (Condition 1) then (Yes)
        :Task 2;
        if (Condition 2) then (Yes)
            :Task 3;        
        endif       
    endif
backward: Continue Loop;
repeat while (More Data?) is (Yes) not (No)

end
@enduml

enter image description here

Axel Kemper
  • 10,544
  • 2
  • 31
  • 54
  • The hexagonal notation is not UML compliant. There is some compliance option for sure (not using it so often so I forgot its name). – qwerty_so Dec 12 '22 at 23:09
  • The OP said the `Continue loop` is not really an action but something he want's to get rid of. – qwerty_so Dec 12 '22 at 23:14
  • @qwerty_so `skinparam conditionStyle diamond` is the option, but I don't understand what this has to do with PlantUML (it's not a UML question, and the OP's diagram would also have the hexagons). – Fuhrmanator Dec 13 '22 at 02:11
  • @Fuhrmanator It's a general observation. PlantUML is nice, but inventing it's own UML style (arrows and decision) is not. They should not carry UML as part of the name. Also I remember some `strict` parameter to render _correct_ arrows. – qwerty_so Dec 13 '22 at 13:36
  • @qwerty_so `skinparam style strictuml` is maybe what you were thinking of? I agree PlantUML is non-standard, but as a diagramming tool it's pretty good and has likely made UML more popular over the years (I've been teaching UML for 20 years). I wish the OMG had looked at how UML was being used as much as PlantUML's dev does. – Fuhrmanator Dec 14 '22 at 14:43
  • @Fuhrmanator I agree in all you said :-) – qwerty_so Dec 14 '22 at 15:26