taakScripts are responsible for invoking procedures
in the middle tier, retrieving data, and transforming xhtml documents
to make them dynamic.
Scripts are composed of one or more taakStatements.
Scripts can be included in other scripts through the import statement.
There are statements for:
- Flow control
- Manipulating variables
- Defining functions
- Invoking functions
- Instantiating Java objects
- Invoking Java methods.
There are also primitives for arithmetic and logical computation and
manipulating an xhtml document.
taakScript syntax derives from a variety of
other scripting languages. As in Basic, you do not need to define variables
before use. As in Perl, you need to terminate each statement with a semicolon.
As in JavaScript you need to define your functions before you call them.
As in Unix command scripts, the single line comment character is #. And
as in Java multi-lines comments are delimited with /* and */.
You can instantiate Java classes, invoke Java methods, and reference
Java objects easily in a Taak script using a simple command syntax.
A sample taakScript follows:
# define a new function to
add one to a number
function addOne(x) {
return x + 1;
}
a = 1; # assign 1 to the variable a
y = addOne(1); # invoke the function (y should be 2)
list = new ArrayList(); # this refers to java.lang.ArrayList
list.add(y); # use as you would a Java ArrayList object
list.add(2);
list.add(3);
print list[0]; # print the first element of the list
list[1] = 9; # change the second element in the list
foreach n in list { # iterates through the list
print n;
}
When executed, this script will print out: 2293
|