how to code subroutine call in Activity diagram

0 votes
asked Jan 31, 2021 in Question / help by lightsalmoncurry (120 points)
I am a newbie in plantuml, even UML, who can only hand-write a flowchart. I wonder how to write a subroutine call in the main activity diagram and split the code block explaining the subroutine itself after the finish of the main loop. Inside the main loop, I wish to call my subroutine several times. And after its end, I wish to add sub-activity diagram as if a document finishes with its footnote like below. Thanks in advance for your kind advice.

```

@startuml

start

;

if (i % 3 == 0 && i % 5 ==0) then (true)

:call subroutine;

note right

subroutine will be explained as a footnote
end note

endif

stop

start

:the subroutine;

if (%i == 3) then (true)

i+=1

endif
 stop

@enduml

```

1 Answer

0 votes
answered Feb 2, 2021 by The-Lu (63,920 points)

Hello L.,

Just add ':' and ';' around 'i+=1'.

@startuml
start
if (i % 3 == 0 && i % 5 ==0) then (true)
  :call subroutine;
  note right
  subroutine will be explained as a footnote
  end note
endif
stop

start
:the subroutine;
if (%i == 3) then (true)
  :i+=1;
endif
stop
@enduml

Then we can observe the expected result:


[See on PlantUML online server]

If that can help,
Regards,
Th.

...