Custom functions and methods can be used to enhance expression capabilities due to the use of custom calculation methods. Custom functions are available for use in:
Calculated series calculation methods in theTime Series Analysis tool.
Model calculation methods in theModeling and Forecasting tool.
Function wizard in the Reports tool.
Formula editor in the Calculation Algorithms tool.
Custom functions are not connected to the tools by default, and they should be entered manually in the expression each time to be used. Foresight Analytics Platform enables the user to connect custom functions to system functions in all tools defined above.
NOTE. Connecting custom functions is available for the users included in the Administrators group.
For example, in the expression editor they are displayed on the functions panel in the Custom Functions category:
To connect custom functions, use the Methods tab in the Custom Metadata section of the Parameters dialog box. All methods added on this tab will be connected to the custom functions section in the Foresight Analytics Platform tools.
The tab contains custom functions divided by folders. Folders are categories that are used to arrange and group functions. Custom functions grouped by categories are displayed in the Time Series Analysis and Modeling and Forecasting tools. In the expression editor and the Calculation Algorithms and Reports tools, custom functions are displayed without division on categories.
Requirements to custom functions:
Functions must be written in the Fore language, must have the Public identifier and must be saved in the current repository as a form, Fore unit, or Fore assembly.
If calculation uses data series or modeling variables, the should be of the ITimeSeries type. To return values calculated by the function, the data of the ITimeSeries type should also be used.
NOTE. A custom function should have a unique name. If after a unit or assembly is selected that contains a function, which name matches with any function or system method or function added before, an exception is thrown. The use of such a unit or assembly will be unavailable.
Set up method or category order
Functions and methods can be used as a custom function.
Custom method. Syntax:
Sub MyFunc(Factor1, Factor2: ITimeSeries; Var Output: ITimeSeries; Coef1: Double; Coef2: Double);
Begin
...
End Sub MyFunc;
Method parameters:
Factor1, Factor2. Data.
Output. Data that will be changed and returned in calculation results.
Coef1, Coef2. Parameters with real values.
Custom function. Syntax:
Function MyFunc(Input, Input1: ITimeSeries; Coef: Double): ITimeSeries;
Var
Output: ITimeSeries;
Begin
...
Return Output;
End Function MyFunc;
Function parameters:
Input, Input1. Data.
Coef. Parameter with a real value.
Output. Variable that returns function calculation result.
See also: