Function _paratype() Foundation
Determines the type of an array element in a multidimensional array.
ULONG _paratype(XppParamList pList, ULONG ulIndex, ...);
Returns the array element type. If ulIndex is referencing a parameter that is not an array then XPP_ILLEGAL is returned.
_paratype() in connection with _paralen() determines the structure and size of multidimensional arrays. If the first array index of _paratype() is NULL, the type of the parameter is returned. If indexes not equal to NULL are passed, the parameter must be an array and the return value describes the type of the specified element. In CA-Clipper, the function _parinfa() is used to determine similar information, but it does not support multidimensional arrays.
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:
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 |
Since the elements of an array in Xbase++ are permitted to have different types, each element should be explicitly tested before its value is accessed.
/*
Copies the first 10 characters of a character string in a two
dimensional array
*/
#include <xpppar.h>
ULONG num = 1;
ULONG len;
CHAR buffer[10];
/* Is the first parameter an array? */
if ( XPP_IS_ARRAY( _paratype(<pList>, num, 0) ) )
{
/* Is first element also an array? */
if ( XPP_IS_ARRAY( _paratype(<pList>, num, 1, 0) ) )
{
/* Is first element of the subarray a string? */
if ( XPP_IS_CHAR( _paratype(<pList>, num, 1, 1, 0) ) )
{
/* copy string */
len = _parc(buffer, sizeof(buffer), <pList>, num, 1, 1, 0);
}
}
}
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.