Prev | Next |
Entry points and Multiple Scriplets
When using a single Scriplet it requires an entrypoint for the execution of the Scriptlet. As this invocation is in the global scope, the Scriptlet will execute when it is loaded. For example the line: Scriplet3() is the entry point for:
function Scriptlet3()
{
var element as EA.Element;
var object as EA.DiagramObject;
element = FindDiagramElement("Discussion1");
if(element)
{
object = FindDiagramObject(element.ElementID);
object.BackgroundColor = parseInt("0xc0c0c0",16);
object.Update();
}
}
Scriptlet3();
It is possible to have Scriptlets that simply define functions that are called by other Scriptlets. One could have a single Scriptlet with an entry point, for example, and several other Scriplets that simply define a library of functions or set some data.
There should, however, be at least one entrypoint defined in one of the diagram's Scriptlets. Where there are multiple Scriptlets and only one entrypoint, the Scriptlet with the entrypoint should be the last to run.
To set the ordering, in which these are compiled and executed, use the z-ordering and set the main Scriplet with the entry point to higher than the others and hence the last to run.