Simple default value for undefined variables

+1 vote
asked Mar 17, 2021 in Wanted features by Todd Musheno

It would be nice to be able to assign a value to a variable, ONLY IF it is not already defined, I have some diagrams that I would like to be stand alone, but would also like to inject values into when running (independent of the diagram).

So I would like to assign a value to a preprocessor value ONLY when not specified from a -D command line option, or defined before the diagram was !included in a simple manner (not using a bunch of tricky !if statements).

I suggest a syntax similar to:

$varable ?= "default value"

commented Mar 17, 2021 by Martin (9,120 points)

it would be equivalent to

!if %not(%variable_exists("$varable"))
!$varable = "default value"
!endif

but less verbose.

commented Mar 17, 2021 by Todd Musheno (2,680 points)
Correct, its just really ugly if there are a bunch of these.
commented Sep 30, 2022 by Todd Musheno (2,680 points)
Not sure why I cannot close this one?

1 Answer

0 votes
answered Mar 18, 2021 by plantuml (295,800 points)
commented Mar 18, 2021 by Todd Musheno (2,680 points)
That works great!
commented Mar 18, 2021 by Todd Musheno (2,680 points)
Do you need to update any documentation???
commented Mar 22, 2021 by The-Lu (74,900 points)

Hello T.,

Yes, of course.wink
It is done, here:

Regards,
Th.

...