variable increased 2 times in diagram (maybe function is called twice during preprocessing)

0 votes
asked Dec 13, 2020 in Question / help by anonymous
I use an `Inc()` function in a diagram and this works, but if I use it as argument of a procedure() then it is increase 2 times. 
Details see below (I use current plantuml server, v 1.2020.23beta3)

Does somebody knows a solution?
Thank you and best regards
Helmut

```

@startuml
!$lastIndex = 0
!$index = 1

!function Inc()
  !$lastIndex = $index
  !$index = $lastIndex + 1
  !return $lastIndex
!endfunction

!unquoted procedure Rel_($e_index, $alias1, $alias2, $label, $direction="")
$alias1 $direction $alias2 : **$e_index: $label**
!endprocedure

!unquoted procedure RelIndex($e_index, $from, $to, $label)
  $from -->>$to : **$e_index: $label**
!endprocedure

' 1         2        3
Inc() -->> Inc() : Inc()

'          4
RelIndex(Inc(), A, B, "Should be 4")
'          5
RelIndex(Inc(), A, B, "Should be 5")
@enduml

```
PlantUML diagram
commented Dec 14, 2020 by The-Lu (63,920 points)

Hello A.,

Adapted from your example, here is another minimal example :

@startuml
!global $lastIndex = 1

!function Inc()
  !$lastIndex = $lastIndex + 1
  !return $lastIndex
!endfunction

!procedure RelIndex($e_index, $label)
:**$e_index** : $label;
!endprocedure

RelIndex(Inc(), "Should be 2")
RelIndex(Inc(), "Should be 3")
RelIndex(Inc(), "Should be 4")
@enduml

Regard,
Th.

1 Answer

0 votes
answered Dec 14, 2020 by plantuml (294,960 points)
Thanks for the report !

This should be fixed in last beta http://beta.plantuml.net/plantuml.jar

Tell us if you find other issues or if it's not working for you.
commented Dec 14, 2020 by anonymous
Thank you for the fast response, it works PERFECT.
Do you have a rough idea when it is on the official http://www.plantuml.com/plantuml server?

Best regards
Helmut
commented Dec 18, 2020 by The-Lu (63,920 points)

FYI, it is now released.

Thanks for the PlantUML team,
Regards,
Th.

commented Dec 19, 2020 by kirchsth
Thank you for the fast support

Best regards

Helmut
...