Book a Demo

Author Topic: Shape script not expanding #<property name># macros  (Read 4231 times)

RusDavies

  • EA Novice
  • *
  • Posts: 16
  • Karma: +1/-0
    • View Profile
Shape script not expanding #<property name># macros
« on: January 27, 2016, 02:51:08 am »
Hello.

Although I've been using EA heavily since about 2004, I'm still fairly new to the horrors of Shape Script. So, if this is silly question, please forgive me.

As I understand it, Shape Script has the capability to expand properties and tags into strings, using the #<property name># notation.  So, for example, if I want to print out the name of an image that is semantically associated with a stereotype, I might do something like this:

Code: [Select]
print("#stereotype#.emf");

If my stereotype is "bob", then the above prints out "bob.emf".  Marvellous.   

What if I then want to display the image?  Let's say our stereotype is again "bob", and I've already imported an image named "bob.emf".  I kind of expected this to work:

Code: [Select]
image("#stereotype#.emf", 0, 0, 100, 100);

And drum roll..... and nothing.  Nada.  Squat.  Not even a rude message.  The image simply isn't displayed.

So, my question is, why not?  Is my expectation all wrong?  For example, is the macro expansion performed by the print function itself, but not by the image function, rather than by some pre-parser?

Thanks.




qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Shape script not expanding #<property name># macros
« Reply #1 on: January 27, 2016, 06:54:01 am »
Welcome to EA (after 10 years). That's what I coined EAUI (EA Unique Interface). You are open to report a bug. But don't hold your breath.

As a very ugly work around: know which stereotypes you deal with and pack it in a long if-clause since the hasProperty can do it.

q.

RusDavies

  • EA Novice
  • *
  • Posts: 16
  • Karma: +1/-0
    • View Profile
Re: Shape script not expanding #<property name># macros
« Reply #2 on: January 27, 2016, 07:32:01 am »
Thanks for the reply qwerty. 

It's starting to feel as if Shape Script was a born as a half-hearted effort after a particularly heavy night on the sauce.   

Will file the macro non-expansion as a bug.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Shape script not expanding #<property name># macros
« Reply #3 on: January 27, 2016, 08:35:16 am »
is the macro expansion performed by the print function itself
Exactly. Think of it more like C style printf support than a language feature like the new C# 6 string interpolation.
« Last Edit: January 27, 2016, 08:43:40 am by Simon M »