Specifies how to pass arrays to COM objects.
COMARRAY(oObject [, nNewValue])
- Specifies an object reference to a COM object.
Specifies how to pass an array to a COM object specified with oObject.
The following table lists the settings for nNewValue and how the to pass the array to the COM object.
To return the current setting, call COMARRAY(В ) without an argument for the nNewValue parameter.
The array is a zero-based array and is passed by value.
The array is a one-based array and is passed by value. Compatible with earlier versions of Visual FoxPro. (Default)
The array is a zero-based array and is passed by reference.
The array is a one-based array and is passed by reference.
The array is a fixed size array and cannot be redimensioned.
Byte arrays are not converted to strings.
Numeric. COMARRAY(В ) returns the current setting.
Use COMARRAY(В ) only when you pass arrays to COM objects using the following syntax:
|If you omit the at sign (@), only the first element of the array passes to the COM object, and COMARRAY(В ) has no effect. This behavior is the same as that in earlier versions of Visual FoxPro.|
When you use a byte array (VT_UI1) to communicate with a COM server, Visual FoxPro converts the byte array into a string. The additive nValue of 1000 retains the original proper type of the array and does not convert the result to a string.
If a client passes a byte array by reference to a Visual FoxPro COM Server, the Visual FoxPro COM Server must also set the nValue additive to 1000. You can do this by putting the following call in the Init event of the Visual FoxPro COM Server:
The additive nValue of 100 makes it possible for you to prevent redimensioning of an array. You should check for possible errors after calling the server in case the server attempts to redimension the array. The following example shows how to prevent redimensioning of the array. To run this example, first build the class definition into a DLL named "t1.dll".
LOCAL loSvr, laTest loSvr = NEWOBJECT("t1.arrayhandler") DIMENSION laTest laTest=3 ? COMARRAY(loSvr,11 + 100) * The COM server will return an error on the next line of code * because arrays passed to loSvr will not allow re-dimensioning. loSvr.RedimensionArray(@laTest,4) ? ALEN(laTest) DEFINE CLASS ARRAYHANDLER AS CUSTOM OLEPUBLIC PROCEDURE RedimensionArray(aArray, nRows) DIME aArray[nRows] ENDPROC ENDDEFINE