static	char	sccsid[]="%Z% %M% %I% %E% %U%";
/******************************************************************************
*                                                                             *
*      処理目的　　：  配列処理                                               *
*                                                                             *
*                                                                             *
*      処理概要　　：　                                                       *
*                                                                             *
******************************************************************************/
#include <colmn.h>

extern CLPRTBL  *pCLprocTable;
extern GlobalCt  *pGlobTable;
extern CLCOMMON CLcommon;
extern int giOptions[];

/****************************************/
/*										*/
/****************************************/
int cl_get_array_index(pInfoParm,pIndex)
tdtInfoParm *pInfoParm;
tdtArrayIndex *pIndex;
{
	char c;
	int  rc;

	if (!pInfoParm) return -1;
	if (((c=pInfoParm->pi_id)=='A' || c=='R') &&
		pInfoParm->pi_dlen == sizeof(tdtArrayIndex)) {
		memcpy(pIndex,pInfoParm->pi_data,sizeof(tdtArrayIndex));

DEBUGOUT_InfoParm(194,"_getArrayIndex: ",pInfoParm,0,0);

		rc = 0;
	}
	else rc = ECL_SYSTEM_ERROR;
	return rc;
}

/****************************************/
/*										*/
/****************************************/
int cl_get_array_index_tbl(pInfoParm,pIndex,ppTBL,pMsg)
tdtInfoParm *pInfoParm;
tdtArrayIndex *pIndex;
tdtInfoParm ****ppTBL;
char *pMsg;
{
	ScrPrCT	*pScCT;
	ProcCT  *proc;
	int *index;
	tdtInfoParm ***pTBL,*pInfo;
	int iRc,*pSize;
	char c,*name,cn;

	if (ppTBL) *ppTBL = NULL;
	if (!pIndex) return -1;
	memset(pIndex,0,sizeof(tdtArrayIndex));
	if ((c=pInfoParm->pi_id) != 'R') {
		if (pScCT = cl_search_src_ct()) {
			pTBL = pScCT->Vary->pTBL_dolu;
			if (c == 'A') {
				name = (char *)pInfoParm->pi_pos;
/*
printf("cl_get_array_index_tbl: name=[%s]\n",name);
*/
				if ((cn=*name) == '#')
					pTBL = pScCT->Vary->pTBL_igeta;
				else if (cn == '%') {
					if (pInfoParm->pi_aux[1] & D_AUX1_LOCAL_VAR) {
						if (!(proc = cl_search_proc_ct())) return SysError;
						pTBL = proc->pTBL_pasento;
					}
					else
						pTBL = pScCT->Vary->pTBL_pasento;
				}
			}
			if (ppTBL) *ppTBL = pTBL;
			pSize = (int *)pTBL[0];
		}
		else return -1;
	}
	else if (c == 'R') {
		if (pInfo=(tdtInfoParm *)pInfoParm->pi_paux) {
			if (pInfo->pi_id != 'R') {
				if (!(name=(char *)pInfoParm->pi_pos)) name = AKX_NULL_PRINT;
				/* cl_get_array_index_tbl: 配列[%s]が無効です。 */
				ERROROUT1(FORMAT(231),name);
				return ECL_SCRIPT_ERROR;
			}
		}
	}
	index = pIndex->index;
	if (c == 'A' || c == 'R') {
		if (iRc = cl_get_array_index(pInfoParm,pIndex)) return iRc;
		index[1] *= index[2]*index[3];
	}
	else {
		if (iRc = cl_get_parm_bin(pInfoParm,index,pMsg)) return iRc;
		index[1] = pSize[2] - (index[0] - 1);
	}
	if ((c=='R' && index[0]<0) ||
	    (c!='R' && (index[0]<=0 || index[0]>pSize[2]))) {
		ERROROUT1(FORMAT(232),index[0]);	/* インデックスの初期値(%d)が不正です。 */
		return -1;
	}
	return 0;
}

/****************************************/
/*										*/
/****************************************/
int cl_check_use_mapped_array(pInfoParm)
tdtInfoParm *pInfoParm;
{
	char *name,c;

	if (pInfoParm->pi_id == 'A') {
		name = (char *)pInfoParm->pi_pos;
/*
printf("cl_check_use_mapped_array: name=[%s]\n",name);
*/
		if ((c=*name)=='%' || c=='#') {
			ERROROUT1(FORMAT(233),name);	/* 指定できない配列名(%s)です。 */
			return -1;
		}
	}
	return 0;
}

/****************************************/
/*										*/
/****************************************/
int cl_check_use_hash_array(pInfoParmArray,pIndex)
tdtInfoParm *pInfoParmArray;
tdtArrayIndex *pIndex;
{
	if (pIndex->xhp ||
	    (pInfoParmArray->pi_id=='R' && (pIndex->index[MAX_ARRAY_DIM+1] & 0x80))) {
		/* cl_check_use_hash_array: can't use hash array[%s]!! */
		ERROROUT1(FORMAT(234),(char *)pInfoParmArray->pi_pos);
		return -1;
	}
	return 0;
}

/****************************************/
/*										*/
/****************************************/
tdtInfoParm *cl_get_array_and_var_ent_opt(pIndex,pTBL,ix,opt)
tdtArrayIndex *pIndex;
tdtInfoParm ***pTBL;
int  ix;
char opt;
{
	int iRc,attr,attr0,iParm[4];
	tdtInfoParm *pInfoParm,rInfoParm;

	pInfoParm = NULL;
	if (pTBL) pInfoParm = cl_get_var_ent(pTBL,ix);
	else if (pIndex) {
		attr = pIndex->uAttr[0];
		if (attr) {
#if 1
			attr0 = 0;
			if ((attr==DEF_ZOK_CHAR || attr==DEF_ZOK_BULK) && !pIndex->size) {
				attr0 = attr;
				attr = DEF_ZOK_VARI;
/*
printf("cl_get_array_and_var_ent_opt: ix=%d opt=%c attr0=%d\n",ix,opt,attr0);
*/
			}
#endif
			if (attr == DEF_ZOK_VARI) {
				pInfoParm = cl_get_array_ent_opt(pIndex->pVarIndex,ix,opt);
#if 1
				if (pInfoParm) {
					if (attr0 && !pInfoParm->pi_aux[0]) {
						iParm[0] = attr0;
						iParm[1] = 0;
						cl_set_parm_init(pInfoParm,iParm,0x01);
					}
				}
#endif
			}
			else {
				if (!cl_get_array_val_opt(&rInfoParm,pIndex,ix,'s'))
					pInfoParm = (tdtInfoParm *)rInfoParm.pi_pos;
			}
		}
	}

	return pInfoParm;
}

/****************************************/
/*										*/
/****************************************/
tdtInfoParm *cl_get_array_and_var_ent(pIndex,pTBL,ix)
tdtArrayIndex *pIndex;
tdtInfoParm ***pTBL;
int  ix;
{
	return cl_get_array_and_var_ent_opt(pIndex,pTBL,ix,'s');
}

/****************************************/
/*										*/
/****************************************/
int cl_gx_conv_index(pInfoParm,pIndex)
tdtInfoParm *pInfoParm;
tdtArrayIndex *pIndex;
{
	tdtArrayIndex tIndex;
	int  attr,i,ji_1,mx,iSTART,iIXPOS,f,m1,m2;
	int  n,*index,*index_info,nn,iRANGE;
	char c,*varnam;

	if (!pInfoParm || !pIndex) return ECL_SYSTEM_ERROR;
	c = pInfoParm->pi_id;
	n = pInfoParm->pi_dlen;
/*
printf("cl_gx_conv_index: pInfoParm->pi_id=%c len=%d\n",c,n);
*/
    if ((n == sizeof(tdtArrayIndex)) && ((c == 'A') || (c == 'R'))) {
		if (!pInfoParm->pi_data) return ECL_SYSTEM_ERROR;
		memcpy(&tIndex,pInfoParm->pi_data,n);
		pIndex->pVarIndex = tIndex.pVarIndex;
		pIndex->size = tIndex.size;
		memcpy(pIndex->uAttr,tIndex.uAttr,sizeof(pIndex->uAttr));
		pIndex->xhp = tIndex.xhp;
	}
	else return ECL_SYSTEM_ERROR;

	index = tIndex.index;

DEBUGOUTL4(191,"cl_gx_conv_index: index = %d %d %d %d",
index[0],index[1],index[2],index[3]);

	index_info = pIndex->index;

DEBUGOUTL4(191,"cl_gx_conv_index: index_info = %d %d %d %d",
index_info[0],index_info[1],index_info[2],index_info[3]);

#if 0
	ji_1 = index_info[0] + 1;
#else
	ji_1 = X_MIN(index_info[0],MAX_ARRAY_DIM);
/*	ji_1++;	*/
#endif
	iSTART = pGlobTable->options[14] & 0x01;
	iIXPOS = pGlobTable->options[14] & 0x02;
	iRANGE = index[MAX_ARRAY_DIM+1];
	mx = ji_1;
	f = 1;
	if (!(varnam=(char *)pInfoParm->pi_pos)) varnam = AKX_NULL_PRINT;
/*	for (i=1;i<ji_1;i++) {	*/
	for (i=1;i<=MAX_ARRAY_DIM;i++) {
		if (i <= ji_1) {
			n = index_info[i];
			nn = index[i];
			if (nn <= 0) {
				/* cl_gx_conv_index:[%s]のインデックスサイズが0です。i=%d index=%d (def=None) */
				ERROROUT3(FORMAT(235),varnam,i,n);
				return ECL_SCRIPT_ERROR;
			}
			m1 = 0;
			m2 = nn - 1;
			if (iRANGE & f) {
				m1 = index[i+MAX_ARRAY_DIM+1];
				m2 += m1;
			}
			else if (iSTART) {
				m1++;
				m2++;
			}
			if (n<m1 || n>m2) {
				/* cl_gx_conv_index:[%s]のインデックスが範囲外です。i=%d index=%d (def=%d..%d) */
				ERROROUT5(FORMAT(236),varnam,i,n,m1,m2);
				return ECL_SCRIPT_ERROR;
			}
		}
		else if (index[i] > 1) mx = i;
		f = f<<1;
	}
/*
printf("cl_gx_conv_index: mx=%d ji_1=%d\n",mx,ji_1);
*/
	if (ji_1 > 0) {
		if (iIXPOS) {
			f = 1<<(mx-1);
			n = index_info[mx];
			if (iRANGE & f) n -= index[mx+MAX_ARRAY_DIM+1];
			else if (iSTART) n--;
			f = f>>1;
			for (i=1;i<mx;i++) {
				nn = index_info[mx-i];
				if (iRANGE & f) nn -= index[mx-i+MAX_ARRAY_DIM+1];
				else if (iSTART) nn--;
/*
printf("cl_gx_conv_index: i=%d n=%d nn=%d f=%x\n",i,n,nn,f);
*/
				n = n*index[mx-i] + nn;
				f = f>>1;
			}
		}
		else {
			n = index_info[1];
			if (iRANGE & 0x01) n -= index[MAX_ARRAY_DIM+2];
			else if (iSTART) n--;
			f = 2;
		/*	for (i=2;i<ji_1;i++) {	*/
			for (i=2;i<=mx;i++) {
/*
printf("cl_gx_conv_index: i=%d n=%d\n",i,n);
*/
				nn = index_info[i];
				if (iRANGE & f) nn -= index[i+MAX_ARRAY_DIM+1];
				else if (iSTART) nn--;
				n = n*index[i] + nn;
				f = f<<1;
			}
		}
	}
/*
printf("cl_gx_conv_index: n=%d\n",n);
*/
	return n + index[0];
}

/****************************************/
/*										*/
/****************************************/
tdtInfoParm *cl_get_array_ent_opt(pVarIndex,iParmNo,opt)
tdtInfoParm *pVarIndex[];
int iParmNo;
char opt;
{
	tdtInfoParm *pDummy;

	if (!pVarIndex) return NULL;

	if (!(pDummy = pVarIndex[--iParmNo])) {
		if (opt == 's' || (pGlobTable->options[0] & 0x01)) {
			if (pDummy=(tdtInfoParm *)Malloc(sizeof(tdtInfoParm))) {
				memset(pDummy,0,sizeof(tdtInfoParm));
				pVarIndex[iParmNo] = pDummy;
				if (pGlobTable->options[0] & 0x01) cl_null_data(pDummy);
			}
		}
	}
	return pDummy;
}

/****************************************/
/*										*/
/****************************************/
tdtInfoParm *cl_get_array_ent(pVarIndex,iParmNo)
tdtInfoParm *pVarIndex[];
int iParmNo;
{
	return cl_get_array_ent_opt(pVarIndex,iParmNo,'s');
}

/****************************************/
/*										*/
/****************************************/
int cl_free_array_ent(pIndex)
tdtArrayIndex *pIndex;
{
	tdtInfoParm *cpDat,**pVarIndex,**p,*pDummy;
	int *index;
	int i,n,ix,k,maxreg,attr;
	XHASHB *xhp;

	if ((xhp=(XHASHB *)pIndex->xhp)) {
		maxreg = akxs_xhash(xhp,'m',NULL);
		for (k=1;k<=maxreg;k++) {
			xhp->xha_xhix = k;
			ix = akxs_xhash2(xhp,'k',NULL,&cpDat);
			if (ix > 0) {
				memcpy(&pDummy,cpDat,sizeof(tdtInfoParm *));
				if (pDummy) {
					cl_free_info_parm(pDummy);
					Free(pDummy);
				}
			}
		}
		akxs_xhash_free(xhp);
		pIndex->xhp = NULL;
		if (pVarIndex = pIndex->pVarIndex) {
			if (!(pIndex->uAttr[1] & D_ATR1_NO_MALLOC)) Free(pVarIndex);
			pIndex->pVarIndex = NULL;
		}
	}
	else if (pVarIndex = pIndex->pVarIndex) {
		if (((attr=pIndex->uAttr[0])==DEF_ZOK_VARI) ||
		    ((attr==DEF_ZOK_CHAR || attr==DEF_ZOK_BULK) && !pIndex->size)) {
			index = pIndex->index;
			n = index[1]*index[2]*index[3];
			for (i=0,p=pVarIndex;i<n;i++,p++) {
				if (pDummy = *p) {
					cl_free_info_parm(pDummy);
					Free(pDummy);
				}
			}
		}
		if (!(pIndex->uAttr[1] & D_ATR1_NO_MALLOC)) Free(pVarIndex);
		pIndex->pVarIndex = NULL;
	}
	return 0;
}

/****************************************/
/*										*/
/****************************************/
int cl_get_array_val_opt(pInfoParmW,pIndex,iParmNo,opt)
tdtInfoParm *pInfoParmW;
tdtArrayIndex *pIndex;
int iParmNo;
char opt;
{
	tdtInfoParm *pInfoParm, *pParm;
	char *p,*pp;
	int *pi,val,attr,len,size;
	double *pd;

	if (!pIndex) return -1;
	attr = pIndex->uAttr[0];
	size = pIndex->size;
DEBUGOUTL2(194,"cl_get_array_val_opt: attr=%d size=%d",attr,size);
	if (!attr) {
		/* cl_get_array_val_opt: can't use hash arrray!! */
		ERROROUT(FORMAT(237));
		return ECL_SCRIPT_ERROR;
	}
	p = (char *)pIndex->pVarIndex;
	iParmNo--;
	if (opt == 's') {
		if (!(pInfoParm=(tdtInfoParm *)cl_tmp_const_malloc(sizeof(tdtInfoParm))))
			return ECL_SYSTEM_ERROR;
		pParm = pInfoParm;
	}
	else if (!(pParm = pInfoParmW)) return -1;

	if (attr == DEF_ZOK_BINA) {
		pp = (char *)&((int *)p)[iParmNo];
		cl_set_parm_bin(pParm,*(int *)pp);
	}
	else if (attr == DEF_ZOK_FLOA) {
		pp = (char *)&((double *)p)[iParmNo];
		cl_set_parm_double(pParm,*(double *)pp);
	}
	else if (attr == DEF_ZOK_DECI) {
		pp = (char *)&((MPA *)p)[iParmNo];
		cl_set_parm_mpa(pParm,(MPA *)pp);
		pParm->pi_hlen = pIndex->uAttr[2];	/* precision */
		pParm->pi_pos = pIndex->uAttr[3];	/* scale */
	}
	else if (attr == DEF_ZOK_CHAR) {
		pp = p + iParmNo*(size+1);
		*(pp+size) = '\0';
		cl_set_parm_char(pParm,pp,strlen(pp));
	}
	else if (attr == DEF_ZOK_DATE) {
		pp = (char *)&((MPA *)p)[iParmNo];
		cl_set_parm_date(pParm,(MPA *)pp);
	}
	else if (attr == DEF_ZOK_BULK) {
		pp = p + iParmNo*(size+sizeof(int));
		memcpy(&len,pp+size,sizeof(int));
		cl_set_parm_char(pParm,pp,len);
		pParm->pi_attr = attr;
	/*	pParm->pi_len = size;	*/
	}
DEBUGOUTL2(194,"cl_get_array_val_opt: p=%08x pp=%08x",p,pp);
DEBUGOUT_InfoParm(194,"cl_get_array_val_opt: iParm-1=%d opt=%c",pParm,iParmNo,opt);
/*
printf("cl_get_array_val_opt: opt=%c attr=%d pp=%08x\n",opt,attr,pp);
*/
	if (opt == 's') {
		pInfoParm->pi_aux[0] = attr;
		pInfoParm->pi_len = size;
		pInfoParm->pi_paux = pp;
		cl_set_parm_long(pInfoParmW,(long)pInfoParm);
		pInfoParmW->pi_id  = 'S';
DEBUGOUT_InfoParm(194,"cl_get_array_val_opt: ",pInfoParmW,0,0);
	}
	return 0;
}

/****************************************/
/*										*/
/****************************************/
int cl_array_get_info_parm(ppParmI,pIndex1,pTBL1,ix1,opt)
tdtInfoParm **ppParmI;
tdtArrayIndex *pIndex1;
tdtInfoParm ***pTBL1;
int ix1;
char opt;
{
	XHASHB *xhp1;
	tdtInfoParm *pParmI;
	int iRc;
	char *cpKey,*cpDat;

	iRc = 0;
	pParmI = NULL;
	xhp1 = pIndex1->xhp;
	if (xhp1) {
		xhp1->xha_xhix = ix1;
		if ((iRc=akxs_xhash2(xhp1,'P',&cpKey,&cpDat)) > 0) {
			memcpy(&pParmI,cpDat,sizeof(tdtInfoParm *));
			xhp1->xha_hashb->ha_key = cpKey;
/*
printf("cl_array_get_info_parm: ix1=%d key=[%s] pParm=%08x\n",ix1,cpKey,pParmI);
*/
		}
	}
	else {
		pParmI = cl_get_array_and_var_ent_opt(pIndex1,pTBL1,ix1,opt);
		iRc = 1;
	}
	*ppParmI = pParmI;
	return iRc;
}

/****************************************/
/*										*/
/****************************************/
int cl_get_array_info(pInfoParm,pIndex,ppTBL,iParm)
tdtInfoParm *pInfoParm;
tdtArrayIndex *pIndex;
tdtInfoParm ****ppTBL;
int iParm[];
{
	int iRc,ix0,*index;
	XHASHB *xhp;

	iParm[0] = iParm[1] = iParm[2] = 0;
	if (iRc=cl_get_array_index_tbl(pInfoParm,pIndex,ppTBL,"cl_get_array_info:")) return iRc;
	if (pInfoParm->pi_id=='R' && (xhp=pIndex->xhp)) {
		iParm[1] = akxs_xhash2(xhp,'M',NULL,NULL);
		iParm[2] = 1;
	}
	else {
		index = pIndex->index;
		iParm[1] = index[1];
		iParm[2] = index[0];
	}
	return 0;
}

/****************************************/
/*										*/
/****************************************/
int cl_get_mapped_array(pInfoParmW,pInfoParm1,pOperator,pInfoParm2)
char *pOperator;
tdtInfoParm *pInfoParm1;
tdtInfoParm *pInfoParm2;
tdtInfoParm *pInfoParmW;
{
	static char *_fn_="cl_get_mapped_array";
	tdtInfoParm *pInfoParmA;
	tdtArrayIndex *pIndex;
	char c,id1,id2;
	int rc,ix,*index,n,i,m,nr;

	if ((c=*pOperator)!='+' && c!='-') {
		/* %s: 演算(%s)は使用できません。 */
		ERROROUT2(FORMAT(238),_fn_,pOperator);
		return ECL_SCRIPT_ERROR;
	}
	if ((id1=pInfoParm1->pi_id) == ' ') {
		if (rc=cl_get_parm_bin(pInfoParm1,&ix,FORMAT(163))) return rc;	/* 左辺 */
		pInfoParmA = pInfoParm2;
	}
	else if ((id2=pInfoParm2->pi_id) == ' ') {
		if (rc=cl_get_parm_bin(pInfoParm2,&ix,FORMAT(164))) return rc;	/* 右辺 */
		pInfoParmA = pInfoParm1;
	}
	pIndex = (tdtArrayIndex *)pInfoParmA->pi_data;
	if (pIndex->xhp) {
		/* %s: 連想配列(%s)は指定できません。 */
		ERROROUT2(FORMAT(239),_fn_,pInfoParmA->pi_pos);
		return ECL_SCRIPT_ERROR;
	}
	if (rc=cl_gx_rep_info_set(pInfoParmW,pInfoParmA,1)) return rc;
/*	if (!(pInfoParmW->pi_data=Memdup(pInfoParmA->pi_data,sizeof(tdtArrayIndex)))) return -1;	*/
	pIndex = (tdtArrayIndex *)pInfoParmW->pi_data;
	pIndex->uAttr[1] = D_ATR1_NO_MALLOC;
	index = pIndex->index;
	n = index[1]*index[2]*index[3];
/*
printf("cl_get_mapped_array: n=%d index[0]=%d index[1]=%d index[2]=%d index[3]=%d\n",
n,index[0],index[1],index[2],index[3]);
*/
	i = index[0] + ix;
	if (i<=0 || i>n) {
		/* %s: map位置(%d)が範囲外です。 */
		ERROROUT2(FORMAT(240),_fn_,i);
		return ECL_SCRIPT_ERROR;
	}
	index[0] = i;
	nr = n - ix;
	index[3] = 1;
	index[2] = 1;
	index[1] = nr;
/*
printf("cl_get_mapped_array: ix=%d nr=%d index[1]=%d index[2]=%d index[3]=%d\n",
ix,nr,index[1],index[2],index[3]);
*/
DEBUGOUT_InfoParm(170,"cl_get_mapped_array: ",pInfoParmW,0,0);

	return 0;
}

/****************************************/
/*										*/
/****************************************/
int cl_array_map(pInfoParmW,nparm,ppParm)
tdtInfoParm *pInfoParmW;
int nparm;
tdtInfoParm *ppParm[];
{
	static char *_fn_="cl_array_map";
	tdtInfoParm *pInfoParmA;
	tdtArrayIndex *pIndex;
	char c,id1,id2;
	int rc,ix,*index,n,i,ind[4],f,iRANGE,iSTART;

	pInfoParmA = ppParm[0];
	if ((id1=pInfoParmA->pi_id)!='A' && id1!='R') {
		/* %s: 第１引数が配列ではありません。id=[%c] */
		ERROROUT2(FORMAT(246),_fn_,id1);
		return ECL_SCRIPT_ERROR;
	}
	pIndex = (tdtArrayIndex *)pInfoParmA->pi_data;
	if (pIndex->xhp) {
		/* %s: 連想配列(%s)は指定できません。 */
		ERROROUT2(FORMAT(239),_fn_,pInfoParmA->pi_pos);
		return ECL_SCRIPT_ERROR;
	}
	if (rc=cl_func_index(&ix,nparm,ppParm)) return rc;
	nparm = X_MIN(nparm-1,MAX_ARRAY_DIM);
	for (i=1;i<=nparm;i++) {
		if (rc=cl_get_parm_bin(ppParm[i],&ind[i],"index")) return rc;
printf("cl_array_map: ind[%d]=%d\n",i,ind[i]);
	}
	if (rc=cl_gx_rep_info_set(pInfoParmW,pInfoParmA,1)) return rc;
/*	if (!(pInfoParmW->pi_data=Memdup(pInfoParmA->pi_data,sizeof(tdtArrayIndex)))) return -1;	*/
	pIndex = (tdtArrayIndex *)pInfoParmW->pi_data;
	index = pIndex->index;
	n = index[1]*index[2]*index[3];

printf("cl_array_map: index=%d %d %d %d n=%d ix=%d\n",
index[0],index[1],index[2],index[3],n,ix);

	i = index[0] + ix;
	if (i<=0 || i>n) {
		/* %s: map位置(%d)が範囲外です。 */
		ERROROUT2(FORMAT(240),_fn_,i);
		return ECL_SCRIPT_ERROR;
	}
	index[0] = i;
	f = 1;
	iRANGE = index[4];
	if (pGlobTable->options[14] & 0x01) iSTART = 1;
	else iSTART = 0;
	
	for (i=1;i<=nparm;i++) {
		if (iRANGE & f)
			index[i] -= ind[i] - index[i+MAX_ARRAY_DIM+1];
		else
			index[i] -= ind[i] - iSTART;
		if (index[i] <= 0) {
			/* %s: map位置(i=%d %d)が範囲外です。 */
			ERROROUT3(FORMAT(247),_fn_,i,ind[i]);
			return ECL_SCRIPT_ERROR;
		}
		f <<= 1;
	}

printf("cl_array_map: index=%d %d %d %d\n",index[0],index[1],index[2],index[3]);

DEBUGOUT_InfoParm(170,"cl_get_mapped_array: ",pInfoParmW,0,0);

	return 0;
}
