Book a Demo

Author Topic: Selecting multiple stereotypes in a hasproperty shapescript statement  (Read 3282 times)

PeteEA

  • EA Novice
  • *
  • Posts: 13
  • Karma: +0/-0
    • View Profile
I want to change the appearance of my elements depending on stereotype. According to the MDG guide, when testing a property in a Shapescript image definition, the propertyvalue parameter can have multiple values, separated by commas. The example uses the "Type" property and I have proved that works: if(HasProperty("Type","Class,Action,Activity,Interface")).

What I actually want to do is: if(hasproperty("stereotype","StereoA,StereoB"))

This doesn't work. If I put just one stereotype StereoA or StereoB as the property value then the rest of my shapescript works, but if I put both in then it doesn't apply to either. Both of these stereotypes are "generalised" from a more generic stereotype where the shapescript is defined.

Are multiple property values not allowed for the stereotype in a hasproperty statement?

Alternatively is there an OR concept in the shapescript language - I can't find it and just trying it doesn't work.

I realise that I can probably sort it with multiple if/else statements, but I'll then need to repeat sections multiple times.

Uffe

  • EA Practitioner
  • ***
  • Posts: 1859
  • Karma: +133/-14
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Re: Selecting multiple stereotypes in a hasproperty shapescript statement
« Reply #1 on: April 06, 2020, 10:55:51 pm »
Hi Pete,

Are multiple property values not allowed for the stereotype in a hasproperty statement?
Hm. Interesting. The documentation doesn't indicate it, but I wouldn't be surprised if stereotypes are actually treated differently from other things which are listed as element/connector "properties".
It might be worth a try to use fully-qualified stereotype names. There's no reason why that should be different, but then there's no reason why stereotypes are different from other properties in the first place.

Quote
Alternatively is there an OR concept in the shapescript language - I can't find it and just trying it doesn't work.
Fraid not. Shape script is very limited and one of the things it doesn't support is logical operators.

Quote
I realise that I can probably sort it with multiple if/else statements, but I'll then need to repeat sections multiple times.
Yeah. It sucks but that's what you need to do.

/Uffe
My theories are always correct, just apply them to the right reality.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Selecting multiple stereotypes in a hasproperty shapescript statement
« Reply #2 on: April 06, 2020, 11:01:27 pm »
You need to get used to EA :-/

Code: [Select]
shape main {
if (HasProperty("Stereotype", "test")) { print("test"); }
if (HasProperty("Stereotype", "test1")) { print("test1");}
}

Will print either stereotype when set. To create an AND you need to nest the if statements. To create an OR you need to copy/paste.

q.