COMARRAY( ) Function

See Also

Specifies how arrays are passed to COM objects.

Syntax

COMARRAY(oObject [, nNewValue])

Returns

Numeric

Arguments

oObject

An object reference to the COM object.

nNewValue

Specifies how an array is passed to the COM object specified with oObject. The following table lists the settings for nNewValue and how the array is passed to the COM object.

nNewValue Description
0 The array is a zero based array, and it is passed by value.
1 (Default) The array is a one based array, and it is passed by value. Compatible with earlier versions of Visual FoxPro.
10 The array is a zero based array, and it is passed by reference.
11 The array is a one based array, and it is passed by reference.

Issue COMARRAY( ) without the nNewValue argument to return the current setting.

Remarks

Earlier versions of Visual FoxPro can only pass arrays to COM objects by value. Also, the array passed to the COM object is assumed be a one-based array, meaning that the first element, row, and column in the array is referenced with 1.

However, some COM objects require that arrays passed to them be passed by reference, or the array passed is zero-based (the first element, row, and column in the array is referenced with 0), or both. COMARRAY( ) lets you specify how the array is passed to the COM object, and assumes you know how the array should be passed to the COM object.

Note that COMARRAY( ) is only used when arrays are passed to COM objects using the following syntax:

oComObject.Method(@MyArray)

If the @ token is omitted, only the first element of the array is passed to the COM object and COMARRAY( ) has no effect.