Apama 10.15.0 | Developing Apama Applications | Developing Apama Applications in EPL | Defining What Happens When Matching Events Are Found | Defining actions | Format for defining actions
 
Format for defining actions
The format for defining an action that takes no parameters and returns no value is as follows:
action actionName() {
   // do something
}
Optionally, an action can do either one or both of the following:
*Accept parameters
*Return a value
The format for defining an action that accepts parameters and returns a value is as follows:
action actionName(type1 param1, type2 param2, ...) returns type3 {
   // do something
  return type3_instance;
}
For example:
action complexAction(integer i, float f) returns string {
   // do something
  return "Hello";
}
An action that accepts input parameters specifies a list of parameter types and corresponding names in parentheses after the action name. Parentheses always follow the action name, in declarations and calls, whether or not there are any parameters. Parameters can be of any valid EPL type. The correlator passes primitive types by value and passes complex types by reference. EPL types and their properties are described in the API Reference for EPL (ApamaDoc) .
When an action returns a value, it must specify the returns keyword followed by the type of value to be returned. In the body of the action, there must be a return statement that specifies a value of the type to be returned. This can be a literal or any variable of the same type as declared in the action definition.
An action can have any name that is not a reserved keyword. Actions with the names onload(), onunload() and ondie() can only appear once and are treated specially as already described in About monitor contents. It is an EPL convention to specify action names with an initial lowercase letter, and a capital for each subsequent word in the action name.
Actions and global variables must not have the same names. See Using action type variables. If you have any code that uses the same identifier for an action and a global variable, you must change it.