Functions
A function is a procedural item that is written in IRL. It is designed to share procedure code between the elements of a ruleset. A function is composed of a header and a statement part.
A function can be created in a rule project to share code procedures across more than one element of a ruleset. A function is expressed in ILOG Rule Language (IRL) and its code is evaluated when the ruleset runs.
A function can be called either from the action part of a rule, from another function, or from an action task of a ruleflow.
You can add as many functions to the rule project as you like. The code that you write in a
function in Rule Designer
is mapped to the IRL function keyword.
Functions can be used to set up the working memory when you test ruleset execution.
The function is composed of a header and a statement part.
The header contains the function return type and its signature. A function signature consists of the function name and an argument list. This list can be either empty or composed of pairs that contain the argument type and name, which are separated by commas.
function returnType functionName (argumentList)
{
code
}
Like the action part of a rule, the statement part can contain any action statements, plus a
return statement.
You use return to exit from the current function. The flow of control returns to
the statement that follows the original function call. The return statement has two
forms: one that returns a value and one that does not. To return a value, put the value (or an
expression that calculates the value) after the return keyword:
return ++count;
The data type of the value that is returned by return must match the type of the
function that is declared as the return value. When a function is declared void, use the form of
return that does not return a value:
return;
throws statement
any subclasses of IlrRuntimeException that might
be thrown during the execution of the function.