Methods: IForeMethods;
The Methods property returns the custom methods collection.
Executing the example requires that the repository contains a unit with the MY_FUNC_ASSEMBLY identifier. The unit implements the PiDiv function.
Sub UserProc;
Var
MB: IMetabase;
SParams: ISharedParams;
Methods: IForeMethods;
Method: IForeMethod;
Begin
MB := MetabaseClass.Active;
SParams := MB.SpecialObject(MetabaseSpecialObject.SharedParams).Edit As ISharedParams;
Methods := SParams.Methods;
Methods.Clear;
//Add a new function
Method := Methods.Add;
//Determine place where function and its parameters are implemented
Method.Assembly := "MY_FUNC_ASSEMBLY";
Method.Method := "PiDiv";
Method.Category := "My functions";
Method.Name := "The 'PiDiv' function";
Method.Description := "Value is divided to 'Pi'";
Method.ResultType := ForeResultType.Real;
Method.Type := ForeMethodType.Arithmetic;
Debug.WriteLine("Method key: " + Method.Key.ToString);
//Save
(Methods As IMetabaseObject).Save;
End Sub UserProc;
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: