About the Script Component API

The Script component provides an API for programmatically configuring the Script component from a Java program.

For more information about component APIs, see Component APIs.

The Script component API consists of the following methods:

  • getString("script"), set("script", scriptText). These methods allow you to get/set the text of the script.

  • getString ("script", supportedLanguages). This method allows you to get the supported languages, as an array of strings.

  • getString ("script", scriptLanguage), setString("script", stringLanguage). These methods allow you to get/set the scripting language. The strings representing the two supported scripting languages are spelled "Jython" and "DynamcJava". If you attempt to set an unsupported language, an exception will be issued.

  • getString ("varName", paramPath). This method retrieves a string that can be inserted into the script to substitute the value of parameter paramPath. The parameter name can be a path to an aggregate variable member. This method is equivalent to the method asParameterSubstitution(String) of class com.engineous.sdk.model.Script.

For example, to create the script (where both agg.mem entries would be highlighted in green in the Script component editor):

agg.mem1 = agg.mem2 + 1;

you could use the code:

scriptApi.set("script", scriptApi.getString("varName", "agg.mem1") +
" = " + scriptApi.get("script", scriptApi.getString("varName", 
"agg.mem2") +
" + 1; ");