define and undef do not work properly

0 votes
asked Dec 19, 2018 in Bug by chillin (140 points)
The following does not work as expected so I consider this a bug (comments in the example), actually there seems to be a define and an undef bug (both of which might be related to definelong in the same context).

@startuml

'define works here
!define STORE

!definelong FRAMEWORK(INSTANCE, STNAME = "abc")

'define is not working here
'!define STORE

!ifdef STORE
node "store: STORE (STNAME)" as STNAME {
}
!else
node "no-store" as STNAME {
}
!endif

!enddefinelong

'should work here but has no effect
'!define STORE

FRAMEWORK(inst1, "def")

'undef seems to have no effect
!undef STORE

FRAMEWORK(inst2, "hij")

@enduml

1 Answer

0 votes
answered Dec 19, 2018 by plantuml (195,460 points)
Unfortunately, create a !define inside a !deflinelong will not work.

Really sorry about that, but you are trying to do something too complex for the preprocessor.

There is a discussion to add some scripting facilities within PlantUML. See http://wiki.plantuml.net/site/plantumlshell

I think that this would be the right way of doing what you want to do. However, this is far from beeing implemented.

You can still put your ideas there so that one day it will be available.

Regards,
commented Dec 20, 2018 by chillin (140 points)
Thanks for the quick answer.
I can accept the fact that a !define *within* a !definelong does not work (yet).
However, should the following be working (a !define outside and *after* a !definelong). The same holds for the !undef.

@startuml

!definelong FRAMEWORK(INSTANCE, STNAME = "abc")

!ifdef STORE
node "store: STORE (STNAME)" as STNAME {
}
!else
node "no-store" as STNAME {
}
!endif

!enddefinelong

'should work here but has no effect
'!define STORE

FRAMEWORK(inst1, "def")

'undef seems to have no effect
!undef STORE

FRAMEWORK(inst2, "hij")

@enduml
commented Dec 21, 2018 by chillin (140 points)
By the way, the suggested scripting features are indeed exactly what I want, but much more elegant and flexible. Right now I'm using the macro definition as a function replacement.
I've added my proposals and suggestions to http://wiki.plantuml.net/site/plantumlshell
Any rough estimate of a timeline for delivering an alpha version of the scripting functionality?
...