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(…)