Please provide an OR logical operator for the ifdef preprocessor command

0 votes
asked Nov 21, 2016 in Closed feature request by boshka (3,940 points)

Please provide an OR logical operator for the ifdef preprocessor command.

Example: !ifdef A || B

1 Answer

0 votes
answered Nov 22, 2016 by Serge Wenger Work (15,620 points)

Hello,

Your proposal is interesting. I do this with a workaround:

@startuml
'define A
!define B

!ifdef A
!define AorB
!else
!ifdef B
!define AorB
!endif

!endif
!ifdef AorB
title A or B
!endif

Bob-> Alice
@enduml

http://www.plantuml.com/plantuml/png/Kqn9JSlCIrLmv5A4ifou53FJW6ma8SVy8g1eQavnAapE2LqkBoKp3Kv1zODaIZ9BSe2A5FAB5E3AdFAJTEqK77CoarC1

Hope this helps

commented Nov 22, 2016 by plantuml (294,960 points)
Very clever workaround!

However, I think we need a better solution.
So in last beta https://dl.dropboxusercontent.com/u/13064071/plantuml.jar

You can have things like:
!ifdef A || B
!ifdef A && B
!ifdef A && ( B || !C )

You can also use | & instead of || && (same meanings).

This has not been highly tested, so do not hesitate to do feedback.

Regards,
commented Nov 22, 2016 by boshka (3,940 points)
Indeed a nice workaround. I used it since I must provide a backwards compatible solution. But anyway, many thanks for adding the new format too.
...