Simple default value for undefined variables

+1 vote
asked Mar 17 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 by Martin (4,880 points)

it would be equivalent to

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

but less verbose.

commented Mar 17 by Todd Musheno (130 points)
Correct, its just really ugly if there are a bunch of these.

1 Answer

0 votes
answered Mar 18 by plantuml (257,860 points)
commented Mar 18 by Todd Musheno (130 points)
That works great!
commented Mar 18 by Todd Musheno (130 points)
Do you need to update any documentation???
commented Mar 22 by The-Lu (31,160 points)

Hello T.,

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