Function _conTypeA() Foundation

Determines the type of an array element.

Syntax
XPPAPIRET _conTypeA(ContainerHandle cha, ULONG *ulType, ...);
Parameters
ContainerHandle cha
Handle of a container of the array type.
ULONG *ulType
Pointer to a ULONG buffer into which the element type is written.
. . .
The remaining arguments must be of the ULONG type and define the element of a multidimensional array. 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 type of the array element could be determined. The function returns an error code (XPP_ERR_...) when the container chais not an array or when the indexes are not valid.

Description

The function _conTypeA() determines the type of an element in the array container cha.

It should be noted that for some types more then one bit is masked in the return value. Furthermore, the numeric value representing a type may change in future Xbase++ versions. Because of these reasons the return value should be tested with one of the macros defined in the header file xpppar.h. The following table lists the macros and the types for which the macro evaluates to true:

Type checking macros
Macro Type Meaning
XPP_IS_UNDEF() XPP_UNDEF NIL
XPP_IS_CHAR() XPP_CHARACTER or XPP_MEMO Character string
XPP_IS_MEMO() XPP_MEMO Memo character string
XPP_IS_NUM() XPP_NUMERIC or XPP_DOUBLE Numeric
XPP_IS_FLOAT() XPP_DOUBLE Floating point
XPP_IS_LOGIC() XPP_LOGICAL Logical
XPP_IS_DATE() XPP_DATE Date
XPP_IS_ARRAY() XPP_ARRAY Array
XPP_IS_BLOCK() XPP_BLOCK Code block
XPP_IS_OBJECT() XPP_OBJECT Object

Examples
/* 
Determines the number of elements in an array passed as a parameter 
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) 
{ 
/* Determines number of elements  */ 
xr = _conSizeA(hArray, &aSize, 0); 
if (xr == 0) 
{ 
   /* Determines type of the first element  */ 
   xr = _conTypeA(hArray, &aeType, 1, 0); 
   if (xr != 0) 
   { 
      /* ... error handling */ 
   } 
   /* Check the type of the first element  */ 
   if( XPP_IS_UNDEF(aeType) ){ 
      /* ... */ 
   }else if( XPP_IS_CHAR(aeType) ){ 
      /* ... */ 
   }else if( XPP_IS_NUM(aeType) ){ 
      /* ... */ 
   }else if( XPP_IS_LOGIC(aeType) ){ 
      /* ... */ 
   }else if( XPP_IS_DATE(aeType) ){ 
      /* ... */ 
   }else if( XPP_IS_ARRAY(aeType) ){ 
      /* ... */ 
   }else if( XPP_IS_BLOCK(aeType) ){ 
      /* ... */ 
   }else if( XPP_IS_OBJECT(aeType) ){ 
      /* ... */ 
   }else{ 
      /* unknown type! ... */ 
   } 
} 
/* 
   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.