Hi I am executing a VB script using script control in c#. If it is a standalone script then it works fine for me by using the below code.
ScriptControl SC = new ScriptControl();
SC.Language = ScriptType;
SC.AddObject("Repository", RP);
SC.AddCode(scriptcontents);
Object[] runobject = { };
string result = SC.Run(ScriptName, runobject);
But when i tried to run a VBScript that contains reference of other scripts then its not executing in the script control and throws error. Referencing other scripts in a script by
!INC Local Scripts.Constants-VBScript
Is there any way to add reference scripts of a script in script control ?
VBscripts in Enterprise Architect have a few "extensions" that are problematic when executing it via a generic scripting host.
!INC <scriptGroup>.<ScriptName>
to include other scripts. This is however an EA specific syntax that is not known to other script interpreters. In order to avoid this you can replace the include statement the whole code of the included script.Dim myVar as EA.Element
this is very useful in the EA script editor because it allows for code completion, but the syntax is not known to any other script interpreter. These type declaration should be removed.scriptController.AddObject("Repository", eaRepository);
For a complete working example see The Enterprise Architect Add-in Framework on Github.
This code reads the scripts from the model and MDG's, takes care of includes, and adds the Repository object.
It doesn't handle variable typing and the Session object.