Add: IForeMethod;
The Add method adds a custom method into the collection.
Executing the example requires that repository contains a unit with the MY_FUNC_ASSEMBLY identifier containing the PiDiv function.
Add links to the Fore and Metabase system assemblies.
Sub UserProc;
Var
Mb: IMetabase;
SharedParams: ISharedParams;
Methods: IForeMethods;
Method: IForeMethod;
Begin
Mb := MetabaseClass.Active;
SharedParams:= Mb.SpecialObject(MetabaseSpecialObject.SharedParams).Edit As ISharedParams;
Methods := SharedParams.Methods;
Method := Methods.Add;
Method.Assembly := "MY_FUNC_ASSEMBLY";
Method.Method := "PiDiv";
Method.Category := "My functions";
Method.Name := "PiDiv";
Method.Description := "Divide value into 'Pi'";
Method.ResultType := ForeResultType.Real;
Method.Type := ForeMethodType.Arithmetic;
Debug.WriteLine("Method key: " + Method.Key.ToString);
(SharedParams As IMetabaseObject).Save;
End Sub UserProc;
Imports Prognoz.Platform.Interop.Fore;
Imports Prognoz.Platform.Interop.KeFore;
Imports Prognoz.Platform.Interop.Metabase;
Public Shared Sub Main(Params: StartParams);
Var
Mb: IMetabase;
SharedParams: ISharedParams;
Methods: IForeMethods;
Method: IForeMethod;
Begin
Mb := Params.Metabase;
SharedParams:= Mb.SpecialObject[MetabaseSpecialObject.msoSharedParams].Edit() As ISharedParams;
Methods := SharedParams.Methods;
Method := Methods.Add();
Method.Assembly := "MY_FUNC_ASSEMBLY";
Method.Method := "PiDiv";
Method.Category := "My functions";
Method.Name := "PiDiv";
Method.Description := "Divide value into 'Pi'";
Method.ResultType := ForeResultType.frtReal;
Method.Type := ForeMethodType.fmtArithmetic;
System.Diagnostics.Debug.WriteLine("Method key: " + Method.Key.ToString());
(SharedParams As IMetabaseObject).Save();
End Sub;
After executing the example a new PiDiv function is added into the collection of the custom methods. After that the function is available for use in various tools without any additional connection of the unit:
See also: