RuleAPI:Procedural commands/Define

From FlexRule Wiki
Jump to: navigation, search


Every single variable to be used in the rule body must be defined first, from which it can be used as a part of the rule logic.


  1. name
    1. Description: Sets the name of each variable
    2. Mandatory: Yes
    3. Type: String
  2. type
    1. Description: Sets the type of each variable
    2. Mandatory: No
    3. Type: Type
      1. friendly name: string representing default primitive types (e.g., int, double, string, datetime, etc.)
      2. full type name: a Namespace and Type name combination (e.g., System.DateTime)
  3. assembly
    1. Description: Defines the assembly name holding the type
    2. Mandatory: No
    3. Type: String
  4. direction
    1. Description: Defines how each variable’s direction can be used
    2. Mandatory: Yes
    3. Types
      1. In: The variables assigned will be given a value before execution.
      2. Out: The result of the procedure will be accessed by the values.
      3. Local: Intended for internal calculation and accessible only inside the procedure that defined it
      4. InOut: Allows input and output for the parameter.
  5. value
    1. Description: Sets the default value for a primitive type of variable
    2. Mandatory: No
    3. Type: Any (string, Int, double, or Boolean); accepts values of primitive types


Defining parameters, there is no need generally to define the type of any parameters.

  1. <Declaration>
  2.     <Define name="order" direction="in"/>
  3.     <Define name="settings" direction="in"/>
  4. </Declaration>

Define with specifying type:

  1. <Declaration>
  2.    <!-- 
  3.      Imports the System.Console class to be used
  4.      In the procedure as a method call
  5.    -->
  6.     <Using path="System.Console"/>
  8.     <Define name="itemNo" type="System.Int32" direction="local"/>
  9. </Declaration>

Define parameter with default value of an empty array:

  1. <Declaration>
  2.     <Define name="orders" type="expression" value="array()" direction="out"/>
  3. </Declaration>