Apama 10.3 | Apama Documentation | Developing Apama Applications | Developing Apama Applications in Event Modeler | Using Functions in Event Modeler | About defining your own functions | Sample function definition file with imports element
Sample function definition file with imports element
Following is a function definition file that specifies the imports element.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE function SYSTEM "http://www.apama.com/dtd/fdf.dtd">
<!--Apama Function Definition File-->
<function name="ExtractTimeField" display-string=”ExtractTimeField"
    <date>17 May 2005</date>
    <author>Ben Spiller</author>
    <comments>External function</comments>
    Return the value of a single field from the specified
    time string (using the TimeFormatPlugin). Date fields
    include 'dd', 'MM' and 'yyyy'. Time fields include 'HH',
    'mm' and 'ss'.
    <import library="TimeFormatPlugin" alias="timePlugin"/>
    <fixed-parameter name="time" type="float" />
    <fixed-parameter name="field identifier" type="string" />
    action #name#(float time, string field_id) returns float
      // If the field string is invalid, make it obvious!
      if field_identifier.length() == 0 {
      return 0.0;
      // Should return 0 if the field specifier is invalid
      return #timePlugin#.format
Notes for this function:
*The value of the function name attribute, ExtractTimeField, is unique within the directory that contains this .fdf file.
*Appears as ExtractTimeField in the Event Modeler rules menu.
*Returns a float.
*The imports element specifies timePlugin as the alias for the plug-in, and TimeFormatPlugin as the shared library that contains the plug-in.
*The code element specifies timePlugin to refer to required plug-in.
*Takes two parameters — a float that specifies a time, and a String that specifies a field ID.
*The EPL ensures that the ID field is valid and then invokes the format function by specifying the alias for the TimeFormatPlugin library:
return #timePlugin#.format

Copyright © 2013-2018 | Software AG, Darmstadt, Germany and/or Software AG USA, Inc., Reston, VA, USA, and/or its subsidiaries and/or its affiliates and/or their licensors.