Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: SvenK on January 09, 2013, 09:36:30 pm
-
Hello,
as there is no feasible way to automatically import a couple of JScripts into EA, I started to investigate in MDG Technologies to do so.
However, I faced some problems:
I maintain a couple of scripts and stored them in different groups. However, the group information is lost when exporting as MDG. Do I have to maintain all scripts in a flat tree? This becomes very confusing.
It is not possible to edit scripts imported from MDG, which is on one hand obvious. However, how do I develop the scripts? Do I need a "master development project file" where the scripts are stored instead of imported as MDG and only develop functionality within this project?
Can I use variables in the !INC command to switch between script groups?
E.g.
var group="MyLocalGroup"
!INC <group>.myscript
var group="MyMdgGroup"
!INC <group>.myscript
Do you have a better workflow to develop JScripts and easily distribute/update them?
Sven
-
It is probably easiest to have a single model where you develop scripts. Yes, they will all be grouped into a group with the technology name.
To avoid needing to change your scripts to reference a group it's probably easiest to put them in a group by that name in the model you are developing them in.
-
Thanks for the hint.
In what table are the scripts stored? I was thinking of writing a script to import other scripts directly into the database.
It's is quite uncomfortable to be not able to versioning our scripts and to make diffs on changes.
Sven
-
It was easier to find than expected:
t_script
-
In the table t_script, the following fields are available:
ScriptCategory: Referece to an GUID; only different for Group or script
ScriptName: Unique GUID
ScriptAuthor: GUID of the Author
Notes: Short description of script type in XML
Script: The actual script content
However, in what table can the ScriptCategory be found.
And how to get a GUID when inserting an new script to the t_script table?
Any help would be appreciated.
Sven
-
From my book Inside EA concerning ScriptCategory:
A value to distinguish between group and script. It looks like a GUID but it has no “{}”
3955A83E-9E54-4810-8053-FACC68CD4782 = group
605A62F7-BCD0-4845-A8D0-7DC45B4D2E3F = script
q.
-
Thanks, so it is only a constant (same values in my project file).
With this I figured out that ScriptAuthor references to the Group where a script is stored (weird name).
So the last think I have to figure out is how to get a new GUID to use it as ScriptName if I add a new script.
-
Hi Sven,
I know this was answered some time ago, somewhere on this forum, bu i can't find it.
Anyways, you can use the GUID generated by the script below,
regards,
Paulus
Dim typeLib
typeLib = CreateObject("Scriptlet.TypeLib")
' GUIDs returned from typeLib have 2 unprintable characters at the end. Strip them off.
GenerateGUID = Left(typeLib.Guid, 38)
-
Thanks!
For the sake of completeness, this is the corresponding JScript code.
function getNewGuid()
{
var typeLib = new ActiveXObject("Scriptlet.TypeLib")
return typeLib.Guid.slice(0,38) // Last two character are unreadable
}
Here are some interesting details on why using TypeLib:
http://blogs.technet.com/b/heyscriptingguy/archive/2005/02/21/how-can-i-create-a-guid-using-a-script.aspx
Sven