Parinfo()

From Recital Documentation Wiki
Jump to: navigation, search

PURPOSE

Check data type of parameters


SYNONYM

api_par_info()


SYNOPSIS

#include "dbapi.h"
 
int	_parinfo(order )
 
<input parameters>
int	order;		/* Placement in list of parameters	*/
 
<output parameters>
none


DESCRIPTION

The _parinfo() function returns the data type of a parameter passed. The order specifies the actual placement in the parameter list. If 0 is specified as the order value then the total number of parameters passed is returned. This function should be used to check the data types of all parameters passed before they are assessed.

The following table contains possible data types that may be passed.


TYPE VALUE DESCRIPTION
API_UTYPE 0 Undefined
API_CTYPE 1 Character
API_NTYPE 2 Numeric
API_LTYPE 4 Logical
API_DTYPE 8 Date
API_MTYPE 16 Memo
API_REFPAR 32 Passed by reference
API_ATYPE 512 Array


EXAMPLE

The following returns .T. if the first parameter passed is a logical.

Example Recital program:

m_value=.t.
m_result=islogical(m_value)
return

Example 'C' function:

#include "dbapi.h"
 
dbapi_islogical()
{
    char	result[10];
 
    if (_parinfo(1) == API_CTYPE) {
       strcpy(result , "Character");
    else if (_parinfo(1) == API_NTYPE)
       strcpy(result , "Numeric");
    else if (_parinfo(1) == API_LTYPE)
       strcpy(result , "Logical");
    else if (_parinfo(1) == API_DTYPE)
       strcpy(result , "Date");
    else if (_parinfo(1) == API_ATYPE)
       strcpy(result , "Array");
    else
       strcpy(result ,"");
 
    _retc( result );
}


SEE ALSO

_parc(), _parclen(), _parcsiz(), _parinfa(), _retc(), _retclen(), CHAR_LTRIM(), CHAR_RPAD(), CHAR_RTRIM(), CHAR_STR(), CHAR_UPPER(), DATE_STOD(), ISARRAY(), ISCHAR(), ISDATE(), ISLOG(), ISMEMO(), ISNUM(), PCOUNT