is the preferred scripting language for TDI (and as of TDI 6.1, the only
scripting language). It is fairly easy to learn, and it provides access to all the underlying Java facilities (though using some of those is not so easy!)
The definitive description of the language is the
For a more gentle introduction, you could try
by Peter Kantor.
And finally, a great Quick Ref can be found here
Using the TDI API
Be aware that most of the results you get by invoking TDI-specific objects are Java objects
This means that their behaviour can sometimes appear extremely odd.
For example, if you call
to get the value of the name
attribute, what you get is a Java string object.
If you compare it directly with another string (i.e. java.lang.String) returned by the same method, it does not work as expected. This is because whenever you work with Java objects, you are actually working with pointers
(called "references") to the actual objects in memory. As a result, the comparison below is not between the values
of these Attributes, but actually a test to see if the returned references are pointing to the same place in memory.
var isEqual = (work.getString("name") == conn.getString("name"));
comparison operators, you have a couple of options: One way is to force the strings to be cast
be directly compared.
engine to convert everything
var isEqual = (work.getString("name") == (conn.getString("name") + "");
However, it is recommended that you do this this kind of typecasting with explicit code:
var isEqual = (work.getString("name") == String(conn.getString("name")));
Another option is to use the Java String methods for string comparison:
var isEqual = work.getString("name").equals( conn.getString("name") );
There is still a hazard though: if there was no name
will return null
type it will result in the string value "null" - probably not what you were expecting!
Caseless string comparison
To compare two string objects (a and b) without regard to case:
(a.toLowerCase() == String( b.toLowerCase() ))
Or, using the Java String comparison method instead:
(a.equalsIgnoreCase( b ))
16 March 2006