Book a Demo

Author Topic: How to use script to change the content of code in effect  (Read 4891 times)

fy1997

  • EA User
  • **
  • Posts: 21
  • Karma: +0/-0
    • View Profile
How to use script to change the content of code in effect
« on: June 11, 2020, 01:17:41 pm »
Does anyone knows how to change the code in effect by using script?

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: How to use script to change the content of code in effect
« Reply #1 on: June 11, 2020, 03:49:30 pm »
I guess you mean the language: EAElement.GenType

q.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: How to use script to change the content of code in effect
« Reply #2 on: June 11, 2020, 04:15:41 pm »
I think he means the code you can type in the field Effect on an Action.

This is actually stored in t_xref with
Name = CustomProperties
Description = @PROP=@NAME=effect@ENDNAME;@TYPE=String@ENDTYPE;@VALU=Code in the effect field@ENDVALU;@PRMT=@ENDPRMT;@ENDPROP;

You might be able to read the field using EA.Element.CustomProperties, but I believe you'll have to update the database directly in order to edit it.
You can use the unsupported and undocumented method Repository.Execute to execute update or insert statements on the database. (at your own risk)

Geert

fy1997

  • EA User
  • **
  • Posts: 21
  • Karma: +0/-0
    • View Profile
Re: How to use script to change the content of code in effect
« Reply #3 on: June 11, 2020, 05:06:56 pm »
I think he means the code you can type in the field Effect on an Action.

This is actually stored in t_xref with
Name = CustomProperties
Description = @PROP=@NAME=effect@ENDNAME;@TYPE=String@ENDTYPE;@VALU=Code in the effect field@ENDVALU;@PRMT=@ENDPRMT;@ENDPROP;

You might be able to read the field using EA.Element.CustomProperties, but I believe you'll have to update the database directly in order to edit it.
You can use the unsupported and undocumented method Repository.Execute to execute update or insert statements on the database. (at your own risk)

Geert


I have no idea how to do it,can you give me a example?Thanks a lot!

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: How to use script to change the content of code in effect
« Reply #4 on: June 11, 2020, 05:14:07 pm »
That would be something like

Code: [Select]
Repository.Execute "update x from t_xref x set x.description = '@PROP=@NAME=effect@ENDNAME;@TYPE=String@ENDTYPE;@VALU=the new code@ENDVALU;@PRMT=@ENDPRMT;@ENDPROP;' where x.Name = 'CustomProperties' and x.Client = '" & myElement.ElementGUID & "'"
Geert

fy1997

  • EA User
  • **
  • Posts: 21
  • Karma: +0/-0
    • View Profile
Re: How to use script to change the content of code in effect
« Reply #5 on: June 11, 2020, 05:44:19 pm »
That would be something like

Code: [Select]
Repository.Execute "update x from t_xref x set x.description = '@PROP=@NAME=effect@ENDNAME;@TYPE=String@ENDTYPE;@VALU=the new code@ENDVALU;@PRMT=@ENDPRMT;@ENDPROP;' where x.Name = 'CustomProperties' and x.Client = '" & myElement.ElementGUID & "'"
Geert


My problem is solved,thanks a lot!

fy1997

  • EA User
  • **
  • Posts: 21
  • Karma: +0/-0
    • View Profile
Re: How to use script to change the content of code in effect
« Reply #6 on: June 12, 2020, 06:41:20 pm »
That would be something like

Code: [Select]
Repository.Execute "update x from t_xref x set x.description = '@PROP=@NAME=effect@ENDNAME;@TYPE=String@ENDTYPE;@VALU=the new code@ENDVALU;@PRMT=@ENDPRMT;@ENDPROP;' where x.Name = 'CustomProperties' and x.Client = '" & myElement.ElementGUID & "'"
Geert

I'm sorry to bother you again, but I have another question. When I want to change the guard of the connector line with script, what should I do?

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: How to use script to change the content of code in effect
« Reply #7 on: June 12, 2020, 06:59:06 pm »
I'm not sure, but I think you'll have to use

EA.Connector.TransitionGuard

You can find the documentation here: https://www.sparxsystems.com/enterprise_architect_user_guide/15.1/automation/connector2_2.html

Geert