Book a Demo

Author Topic: Shape script and properties!  (Read 3334 times)

jguerra

  • EA User
  • **
  • Posts: 39
  • Karma: +0/-0
    • View Profile
Shape script and properties!
« on: November 08, 2008, 01:47:35 am »
Hi,
In a shape script, I want to modify part of the text on an element only when the element is instantiated. I went through the property list and I didn't see anyone indicating something such as "isinstance"or similar. Is there any way to find that out?

Thanks

KP

  • EA Administrator
  • EA Expert
  • *****
  • Posts: 2919
  • Karma: +55/-3
    • View Profile
Re: Shape script and properties!
« Reply #1 on: November 10, 2008, 09:17:36 am »
Could you check for a non-null value of the "classifier" property?

Code: [Select]
if(hasproperty("classifier",""))
{
      print("no classifier");
}
else
{
      print("classifier=#classifier#");
}
The Sparx Team
[email protected]

jguerra

  • EA User
  • **
  • Posts: 39
  • Karma: +0/-0
    • View Profile
Re: Shape script and properties!
« Reply #2 on: November 10, 2008, 10:22:23 pm »
Awesome !!

Thanks for the clues!. I updated the code snipped and this is what it looks like the now.
...
if(hasproperty("classifier",""))
{
        printwrapped("#name#");
} else
{
          printwrapped("#name#:#classifier.name#");
}
...

So, based on the criteria of whether or not we are dealing with an instance, the script prints out the name of the element (no instance, classifier == "") or the pattern <instance_name>:<classifier_name>. The Shape script was tested out on 7.1 b833 with no probs and the code snipped above works nicely and it does what it's meant to do!!

Thanks