Function _conSizeA() Foundation

Determines the number of elements in an array container.

Syntax
XPPAPIRET _conSizeA(ContainerHandle cha, ULONG *ulSize, ...);
Parameters
ContainerHandle cha
Handle of a container of the array type.
ULONG *ulSize
Pointer to a ULONG buffer into which the array size is written.
. . .
The remaining arguments must be of ULONG type and define the subarray within a multidimensional array whose length should be returned. An index is specified per array dimension to select the subarray. Note:The end of the array index list must be indicated by incorporating a NULL as the last value in the list.
Return

Returns NULL when the length of the array could be determined. The function returns an error code (XPP_ERR_...) when the container chais not an array, the indices are not valid, or the selected element is not an array.

Description

Using this function the length of an array, or the length of a subarray in a multidimensional array, can be determined. If the first index is NULL, the length of the passed array container is given. Otherwise the length of the specified subarray is furnished.

Xbase++ has several internal threads which can execute code blocks. Since arrays are always passed by reference, it is possible that two threads could be working with the same array at the same time. Unless an array was created locally in a function, the size or the content of the array may be changed by another thread. Therefore, return values should always be checked, even when the array structure was determined with _conSizeA() and _conTypeA().

Examples
/* 
Determines the number of elements in a parameter which is an array 
and the type of the first element. 
*/ 
#include <xppcon.h> 

ContainerHandle  hArray, 
BOOL             isRef; 
ULONG            aSize; 
ULONG            aeType; 
XPPAPIRET        xr; 


hArray = _conParam(<pList>, 1, &isRef); 
if (hArray != NULLCONTAINER) 
{ 
/* Number of elements ? */ 
xr = _conSizeA(hArray, &aSize, 0); 
if (xr == 0) 
{ 
   /* Type of the first element ? */ 
   xr = _conTypeA(hArray, &aeType, 1, 0); 
   if (xr != 0) 
   { 
      /* ... error handling */ 
   } 

   /* ... test of the type of element 1 */ 
} 
/* 
   release the parameter container 
   (if not passed by reference) 
*/ 
if (!isRef) 
   _conRelease(hArray); 
} 

Feedback

If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.