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 (3,880 points)

it would be equivalent to

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

but less verbose.

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

1 Answer

0 votes
answered Mar 18 by plantuml (251,240 points)
commented Mar 18 by Todd Musheno (110 points)
That works great!
commented Mar 18 by Todd Musheno (110 points)
Do you need to update any documentation???
commented Mar 22 by The-Lu (19,980 points)

Hello T.,

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

Regards,
Th.

...