Book a Demo

Author Topic: [ShapeScript] How to compare strings?  (Read 7384 times)

Boron

  • EA User
  • **
  • Posts: 111
  • Karma: +6/-0
    • View Profile
[ShapeScript] How to compare strings?
« on: June 22, 2015, 04:18:08 pm »
Hello,

I would like to compare the value of a tag with a fixed string.
The elements, where to script applies, have a tag called "ASIL". This tag has an enum type (only five different values selectable in drop-down list).
The shape script shall append an "A" to the name of the element in the diagram if the tag has the value "ASIL A".
The only thing what is not working is the string compare in line 3.

Any idea how strings can be compared?
If not: any alternatives?
Code: [Select]
if(HasTag("ASIL"))
{
   if( "#tag:ASIL#" == "ASIL A") {
      println("#NAME#.(A)");
   }
   else {
      println("#NAME#.(#tag:ASIL#)");
   }
}

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: [ShapeScript] How to compare strings?
« Reply #1 on: June 22, 2015, 04:30:30 pm »
Shape script is very, very simplistic. You can't do that. You need to do it like
Code: [Select]
if(HasTag("ASIL", "ASIL A"))) { ... }The first parameter is the tag name and the second the value.

q.

Boron

  • EA User
  • **
  • Posts: 111
  • Karma: +6/-0
    • View Profile
Re: [ShapeScript] How to compare strings?
« Reply #2 on: June 22, 2015, 04:37:34 pm »
Args, you are right.
I saw this in the documentation but just did not "see" it.

Thanks a lot.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: [ShapeScript] How to compare strings?
« Reply #3 on: June 22, 2015, 04:47:10 pm »
Hard to see the forrest whilst looking at all those trees ;)

q.