Book a Demo

Author Topic: Programmatically set is literal  (Read 3152 times)

entropicrune

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Programmatically set is literal
« on: February 25, 2011, 11:56:34 am »
Hello,

I'm able to programmatically create enumeration values, but I don't see how to set "Is Literal".  Other items from the specification dialog (such as "Derived" and "Static") have accessors (such as isDerived and isStatic) defined on an instance of EA.Attribute (according to the completion menu), but I do not see anything similar for "Is Literal".

I'm using JavaScript.

Thanks!
Art

Aaron B

  • EA Administrator
  • EA User
  • *****
  • Posts: 941
  • Karma: +18/-0
    • View Profile
Re: Programmatically set is literal
« Reply #1 on: February 25, 2011, 01:59:53 pm »
This value is stored in Attribute.StyleEx.  E.g. "IsLiteral=1;"

If there is no "IsLiteral" value in StyleEx for an enum attribute, the default value is treated as true (1).

So effectively you can conclude that if StyleEx contains "IsLiteral=0;", then "Is Literal" is false.

Code: [Select]
function IsLiteral(attribute)
{
  if (attribute.StyleEx.search("IsLiteral=0;") == -1)
  {
    return true;
  }
  else
  {
    return false;
  }
}

To set IsLiteral, you'll need to write to the StyleEx string, being careful not to overwrite other existing information or end up with two "IsLiteral" options.

HTH.