wwDotNetBridge::InvokeMethod_ParameterArray
about 1 minute to read

Like InvokeMethod, but allows passing an arbitrary number of parameters in an array rather than as a named parameter. The array is translated into individual parameters passed into the method called.

Use this method if you need more than 15 parameters to pass to the .NET method. This method allows to get around wwDotnetBridge's 15 parameter and FoxPro's 26 parameter limits.

o.InvokeMethod_ParameterArray(loInst,lcMethod,laParams)

Parameters

loInst
Instance of the .NET object to call the method on.

lcMethod
The name of the method to call as a string.

laParams
A list of parameters. Can be:

    * ComArray Object (see example) * FoxPro Array * FoxPro Collection

Remarks

In some cases you may have to explicitly coerce parameter types by using the VFP CAST() function. This is especially true for numeric values since VFP numbers are typically passed as double or int depending on the existance of decimals. For example, decimal values need CAST(1.11 as Currency). Note that this only works with ComArray.AddItem() - any other assignment to a VFP object or array element simply loses the type information and you may run into problems.

For this reason we recommend you use the ComArray.AddItem() function to set up parameters.

Example

foxpro
*** Passing ComArray instance LOCAL oBridge as wwDotNetBridge oBridge = CREATEOBJECT("wwDotNetBridge") *** Object to call method on loInst = oBridge.CreateInstance("Westwind.WebConnection.wwDotNetBridge") *** Create a COM Array instance with System.Object elements LOCAL loArr as Westwind.WebConnection.ComArray loArr = oBridge.CreateArray("System.Object") *** Add any number of parameters here loArr.AddItem("Hello") loArr.AddItem(CAST(1.0 as Integer)) ? oBridge.InvokeMethod_ParameterArray(loInst, "GetValues",loArr) *** Using an array DIMENSION aParams[2] aParams[1] = "Hello" aParams[2] = 10 ? oBridge.InvokeMethod_ParameterArray(loInst, "GetValues",@aParameters)

See also:

Class wwDotNetBridge

© West Wind Technologies, 1996-2024 • Updated: 04/05/18
Comment or report problem with topic