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 (6,780 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 (130 points)
Correct, its just really ugly if there are a bunch of these.

1 Answer

0 votes
answered Mar 18, 2021 by plantuml (265,600 points)
commented Mar 18, 2021 by Todd Musheno (130 points)
That works great!
commented Mar 18, 2021 by Todd Musheno (130 points)
Do you need to update any documentation???
commented Mar 22, 2021 by The-Lu (37,880 points)

Hello T.,

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

Regards,
Th.

...