use an autonumber reference in another location

+4 votes
asked Aug 1, 2020 in Wanted features by yoni
In a sequence diagram, when autonumber is used, I want to be able to reference to a previous item according to its assigned number. I am aware of the %autonumber% variable, but it is applicable only for the current item I would like to do something like setting a variable to the numbered value of an item, and later use this variable on a text of arrow or note.
commented Aug 17, 2020 by Martin

It's always worth offering some syntax when suggesting a new feature.  E.g. the following Q looks similar, and suggests using a # notation to set named points: https://forum.plantuml.net/1932/autonumber-and-references-in-sequence-diagrams

I tried to use the preprocessor to mess with %autonumber%; but (as its name should have told me), it runs before the diagram is drawn, and so %autonumber% is undefined.  But perhaps some new syntax like:  %autonumber -2% to get the value from 2 steps previous (nb this would be a simple calculation except that autonumbering can be resumed with a different increment/format).  And/or 'autonumber name=myname' plus '%autonumber myname%'.

commented Aug 18, 2020 by yaizik (100 points)
edited Oct 6, 2020 by yaizik
Thanks for the answer. For my needs, the "%autonumber -2" alone is not good enough since I often change the ordering of the sequence over time, add steps in between etc. So as suggested in the other thread, the "#notation" will be a great solution. Also the following which is what I had initially in mind -

@startuml
autonumber "<font color=blue><b>0 "
A->B: message
var %first-message% = %autonumber%  /`This should take the value of the last number that has been used by the autonumber functionality`/
B->A: This is the response to message %first-message%

note over A: This is a note that references message %first-message%

@enduml
commented Nov 23, 2020 by mawi (620 points)

This might be able to be used to suppress autonumbering of a certain line, like requested here:
https://forum.plantuml.net/1087/suppress-numbering-in-selected-messages-sequence-diagram

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.
...