_ALen( ) API Library Routine Example
The following example provides a Visual FoxPro API routine for each of the three possible mode values.
SET LIBRARY TO ALEN
DIMENSION a[10, 11]
? ALENELEM(@a) && returns 110
? ALENSUB1(@a) && returns 10
? ALENSUB2(@a) && returns 11
DIMENSION b[3]
? ALENELEM(@b) && returns 3
? ALENSUB1(@b) && returns 3
? ALENSUB2(@b) && returns 0; no second subscript
c = .F.
? ALENELEM(@c) && returns -1 because variable "c" is not an array
? ALENSUB1(@c) && returns -1 because variable "c" is not an array
? ALENSUB2(@c) && returns -1 because variable "c" is not an array
#include <pro_ext.h>
void FAR alenElem(ParamBlk FAR *parm)
{
_RetInt(_ALen(parm->p[0].loc.l_NTI, AL_ELEMENTS), 10);
}
void FAR alenSub1(ParamBlk FAR *parm)
{
_RetInt(_ALen(parm->p[0].loc.l_NTI, AL_SUBSCRIPT1), 10);
}
void FAR alenSub2(ParamBlk FAR *parm)
{
_RetInt(_ALen(parm->p[0].loc.l_NTI, AL_SUBSCRIPT2), 10);
}
FoxInfo myFoxInfo[] = {
{"ALENELEM", (FPFI) alenElem, 1, "R"},
{"ALENSUB1", (FPFI) alenSub1, 1, "R"},
{"ALENSUB2", (FPFI) alenSub2, 1, "R"},
};
FoxTable _FoxTable = {
(FoxTable FAR *) 0, sizeof(myFoxInfo)/sizeof(FoxInfo), myFoxInfo
};