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 := "The 'PiDiv'" function;
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 := "The 'PiDiv'" function;
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;
On executing the example a new PiDiv function is added to the collection of custom methods.
See also: