Function _conSizeA() Foundation
Determines the number of elements in an array container.
XPPAPIRET _conSizeA(ContainerHandle cha, ULONG *ulSize, ...);
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.
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().
/*
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);
}
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.