Parinfa()

From Lianjapedia
Jump to: navigation, search

PURPOSE

Check data type of any array elements

SYNONYM

api_par_infa()

SYNOPSIS

#include "lianja_api.h"
 
int	_parinfa(order [,index])
 
<input parameters>
int	order;		/* Placement in the array in the parameter list	*/
int	index;		/* Array element index					*/
 
<output parameters>
none

DESCRIPTION

The function returns a value specifying the data type of an array element and is used for parameter checking. Array elements can be of varying data types and must be checked before using. The order specifies the actual placement in the parameter list. The index value is used to specify the required element number in the specified array. If the index value is 0, then the total number of elements in the array will be returned.

The _parinfa() function returns a value from the following table.

TYPE VALUE DESCRIPTION
API_CTYPE 1 Character
API_NTYPE 2 Numeric
API_LTYPE 4 Logical
API_DTYPE 8 Date

EXAMPLE

The following example returns the number of character elements in the array passed as the first parameter.

Example Lianja script:

Declare m_array[2]
m_array[1]="TUESDAY"
m_array[2]="7.1"
m_num_char=numchar(m_array)

Example 'C' function:

#include "lianja_api.h"
 
lianjaapi_numchar()
{
    int	num;
    int	i;
 
    if (_parinfo(1) == API_ATYPE) {
       for (i = 1; i <= _parinfa(1, 0); ++i) {
       if (_parinfa(1,i) == API_CTYPE) {
       }
       }
    } else {
       num = -1;
    }
 
    _retni( num );
}

SEE ALSO

_parinfo(), ALENGTH(), ISARRAY(), ARRAY_ALEN(), ARRAY_DEFINE(), ARRAY_LOOKUP(), ARRAY_UPDATE(), MEMVAR_DEFINE(), MEMVAR_LOOKUP(), MEMVAR_UPDATE()