About Know-how Libraries and Reusable Functions

Enterprise Knowledge Language (EKL) is a procedural language in which code reuse helps avoid code duplication, and enhance code readability and maintainability.

You can define reusable functions in the Quality Rules Capture app. These functions are defined in Know-how libraries objects. Once defined and properly exposed through a local resource table or a Data Setup resource set, the libraries can be included in any EKL script and their functions can be called like any other EKL function.

This page discusses:

Library Content

A library can contain more than one function. Each function has a signature (its parameters) and a body.

The format supports:

  • Multiple functions definition in a single library
  • Methods or functions definition with optional arguments
  • Default values on the optional arguments
  • Description in HTML and plain text for each function.

Library Use

Making a Library Reusable for Reuse

A library must be added to the Includable Libraries Data Setup resource set or in the local resource table of the calling script so that it can be included from a script. This is how the Include keyword knows which libraries are available in the current context.

Libraries can be called from any EKL script using the Include keyword.

Includes are to be located in the first lines of any EKL script before any other instruction.

Include "Lib1"
Include "Lib2"
...
let var1(TypeOfVar1)
...
EKL script

To call a reusable function referenced in a resource table or in a Data Setup table, bear in mind that the name used in the Include statement must be the logical name stored in a resource table and the logical name of a Data Setup library referenced in the Includable EKL Libraries resource set.

Once a library is included, its functions can be called like any other EKL function:

LibName::FunctionName(<args>)

The prefix makes it possible to have several functions with the same name in different libraries to avoid ambiguity when calling a function whose name may be re-used.

Example

A reusable function can include other functions. To do so, use the Include keyword.

Suppose you have defined a Max function that computes the maximum number in a list of Real numbers in a library called MathsTools. If you want to use this function from another EKL script, write:

Include "MathsTools"
[...]
maxInList = MathsTools::Max(listToSearchIn)

All functions from the currently edited library are available in the currently edited function using the following syntax: This::<Function Name>()” or more directly ::<Function Name>()”.

In the MathsTools library, when writing a function, you can use the Max function without any include statement: maxInList = ::Max(listToSearchIn) or maxInList = This::Max(listToSearchIn). This syntax is allowed because both Max and the currently edited function are located in the same library.

In the following configuration:



  • If you want to call a reusable function referenced in a resource table or in a Data Setup resource table, remember that the name used in the Include statement must be a logical name from a resource table library element or a logical name from a Data Setup library referenced in the Includable EKL Libraries resource set.
  • Both includes are correct, the first one uses the local resource table and the other one uses a resource table in Data Setup. In the rule script, you can call functions from Lib1 or Lib2 using the following statements:
    • LibResource1::F1(…)
    • LibResource1::F2(…)
    • LibGlobal1::F3(…)
    • LibGlobal1::F4(…)

Other Information

  • A reusable library cannot be called in a check created in Engineering Rules Capture.
  • A reusable function cannot be called through the server EKL.