contents   index   previous   next



SafeArrayGetNElements

 

(SafeArrayNElements)

 

f90VB Modules

 

f90VBDefs, f90VBSafeArrays

Summary

 

Returns the number of elements of a dimension in a Safe Array.

 

SafeArrayGetNElements is a subroutine. It returns the number of elements of a dimension in argument nElements. SafeArrayNElements is a function whose return value is the number of elements of the passed Safe Array dimension. Function SafeArrayNElements is usually more convenient to use when setting limits to the iterator of a DO loop.

Syntax

 

Syntax Variation 1:

 

integer(LONG_KIND) function SafeArrayNElements (SARef, nDim, iRet)

Syntax Variation 2:

{
integer(SAFEARRAY_KIND),intent(in):: SARef |
type(FSafeArray),intent(in):: SARef |
}
integer(LONG_KIND),intent(in):: nDim
integer(HRESULT_KIND),intent(out),optional:: iRet

 

subroutine SafeArrayGetNElements (SARef, nDim, nElements, iRet)

{
integer(SAFEARRAY_KIND),intent(in):: SARef |
type(FSafeArray),intent(in):: SARef |
}
integer(LONG_KIND),intent(in):: nDim
integer(LONG_KIND),intent(out):: nElements
integer(HRESULT_KIND),intent(out),optional:: iRet

Arguments

 

SARef [Input]

A handle to, or a Fortran Safe Array structure containing a handle to, an allocated Safe Array descriptor.

 

nDim [Input]

The array dimension for which to get the number of elements.

 

nElements [Output]

Variable where the number of elements in the dimension is returned. If you are using Syntax Variation 1, the number of elements in the dimension is returned as the result of function SafeArrayNElements.

 

iRet [Output, Optional]

Upon return, iRet contains S_OK or an error code. See comments for more information.

Comments

 

Note that SARef must be a reference to an allocated Safe Array descriptor.

 

If an error condition occurs, the return value of function SafeArrayNElements is an error code, as described in iRet.

Argument iRet

 

Indicates success or failure of the subroutine. The following codes can be returned in this argument:

 

 

Value returned in argument iRet Description
S_OK Success.
DISP_E_BADINDEX The specified dimension is out of bounds.
E_INVALIDARG The item pointed to by SARef is not a Safe Array descriptor

Examples

 

See example for SafeArrayGetDim.

Related Topics

 

For information about See
Creating a Safe Array SafeArrayCreate
Obtaining the upper bound of an array dimension SafeArrayGetUBound
Obtaining the lower bound of an array dimension SafeArrayGetLBound
Setting the bounds of an array dimension SafeArraySetBounds
Allocating a Safe Array descriptor SafeArrayAllocDescriptor

 


SafeArrayGetUBound