Search code examples
loopsrepeatplantumlactivity-diagram

Repeat while loop after a condition in PlantUML activity diagram


I'm dealing with some difficulties trying to achieve the proper look of the plantuml activity diagram. What I'm getting is on the left, I'd like to receive what's on the right, ie:

  • more straight line of the loop
  • single ending node

reality vs dream

reality vs dream

I've tried this:

@startuml
start
:A;
repeat :B;

if (C) then (yes)
:D;
stop
else (no) 
if(E) then (no)
stop
'repeat while (E) is (yes)
else (yes)

@enduml

but when using "repeat while" I'm getting the error "Cannot find repeat"


Solution

  • Is this nearer to what you are looking for?

    @startuml
    start
    :A;
    repeat :B
      if (C) then (yes)
        :D;
        break
      else (no)
        
      endif
        
      backward :again;
    repeat while (E) is (yes) not (no)
    
    stop
    
    @enduml
    

    enter image description here