User functions must be written in the Fore or Fore.NET language. They can be used in workbooks of the Time Series Analysis tool, in models of the Modeling and Forecasting tool, and in the expression editor.
User functions are not connected to the tools by default, and they should be entered manually each time to be used. Prognoz Platform 9 enables the user to connect user functions to system functions in the expression editor, in time series analysis and in modeling and forecasting at the same time.
For example, in the expression editor they are displayed on the functions panel in the User Functions category:
To connect a user function, use the IForeMethods.Add method. Note that value of the IForeMethod.Type property is used to classify the function (arithmetic, pointwise or series) rather than to determine its calculation mode.
If a user function is arithmetic or pointwise, it must return data of the ITimeSeries interface. If the function is calculated for several data elements, each of the elements is calculated individually. If a user function is a series one, it processes all data elements at the same time.
Functions and methods can be used as a user function.
Series method. Syntax:
Fore:
Sub MyFunc(Factor1, Factor2: ITimeSeries; Var Output: ITimeSeries; Coef1: Double; Coef2: Double);
Begin
...
End Sub MyFunc;
Fore.NET:
Public Shared Sub MyFunc(Factor1, Factor2: ITimeSeries; Var Output: ITimeSeries; Coef1: Double; Coef2: Double);
Begin
...
End Sub;
Method parameters:
Factor1, Factor2. Data.
Output. Data that will be changed and returned in calculation results.
Coef1, Coef2. Parameters with real values.
Pointwise function. Syntax:
Fore:
Function MyFunc(Input, Input1: ITimeSeries; Coef: Double): ITimeSeries;
Var
Output: ITimeSeries;
Begin
...
Return Output;
End Function MyFunc;
Fore.NET:
Public Shared Function MyFunc(Input, Input1: ITimeSeries; Coef: Double): ITimeSeries:
Var
Output: ITimeSeries;
Begin
...
Return Output;
End Function;
Function parameters:
Input, Input1. Data.
Coef. Parameter with a real value.
Output. Variable that returns function calculation result.
See also: