Params: IForeSubParams;
The Params property returns method parameter collection.
Executing the example requires a unit with the MODULE identifier. In the unit global namespace the function is implemented:
Function Calculate(a, b: Integer; c: Double): Double;
Var
Result: Double;
Begin
//...
//Calculate taking into account parameter values
//...
Return Result
End Function Calculate;
Add a link to the Fore, Metabase system assembly.
Sub UserProc;
Var
ForeService: IForeServices;
Runtime: IForeRuntime;
Assm: IForeAssembly;
FSub: IForeSub;
Params: IForeSubParams;
Param: IForeSubParam;
Begin
ForeService := MetabaseClass.Active As IForeServices;
Runtime := ForeService.GetRuntime;
//Load assembly
Runtime.LoadAssembly("MODULE");
Assm := Runtime.BindToAssembly("MODULE");
//Get function
FSub := Assm.BindToSub("Calculate");
//Set parameter values
Params := FSub.Params;
Param := Params.ParamByName("a");
Param.Value := 1;
Param := Params.ParamByName("b");
Param.Value := 2;
Param := Params.ParamByName("c");
Param.Value := 3.14;
//Execute
FSub.Invoke;
//Get information about result
Debug.WriteLine(FSub.ResultName);
Debug.WriteLine(FSub.ResultType);
Debug.WriteLine(FSub.ResultValue);
End Sub UserProc;
Imports Prognoz.Platform.Interop.Fore;
Imports Prognoz.Platform.Interop.Metabase;
Public Shared Sub Main(Params: StartParams);
Var
ForeService: IForeServices;
Runtime: IForeRuntime;
Assm: IForeAssembly;
FSub: IForeSub;
SubParams: IForeSubParams;
Param: IForeSubParam;
Begin
ForeService := Params.Metabase As IForeServices;
Runtime := ForeService.GetRuntime();
//Load assembly
Runtime.LoadAssembly("MODULE");
Assm := Runtime.BindToAssembly("MODULE");
//Get function
FSub := Assm.BindToSub("Calculate");
//Set parameter values
SubParams := FSub.Params;
Param := SubParams.ParamByName("a");
Param.Value := 1;
Param := SubParams.ParamByName("b");
Param.Value := 2;
Param := SubParams.ParamByName("c");
Param.Value := 3.14;
//Execute
FSub.Invoke();
//Get information about result
System.Diagnostics.Debug.WriteLine(FSub.ResultName);
System.Diagnostics.Debug.WriteLine(FSub.ResultType);
System.Diagnostics.Debug.WriteLine(FSub.ResultValue);
End Sub;
On executing the example, the specified unit is loaded to execution environment. The Calculate function will be obtained and its parameter values will be set. After that the function will be executed. information about executed result will be displayed to the development environment console.
See also: