Functions

A function is a procedural item 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 in order 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 executes.

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 testing 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: the argument type and name, separated by commas.

function returnType functionName (argumentList)
{
     code
}

The statement part can contain any action statements, just as in the action part of a rule, 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, simply put the value (or an expression that calculates the value) after the return keyword:

return ++count;

The data type of the value returned by return must match the type of the function’s declared return value. When a function is declared void, use the form of return that does not return a value:

return;
Note: A function is not required to declare in its throws statement any subclasses of IlrRuntimeException that might be thrown during the execution of the function.