/*---------------------------------------------------------------------------*/
/* Array.c : Typed array for AI.*/
/* author : Olivier Couvreur  28/11/1997*/
/*---------------------------------------------------------------------------*/
 
/* included in DsgMem.c so excluded from build in VC project*/
 
#include "AIUseCPA.h"
 
#include "AI_Mmg.h"
#include "specif/AIOption.h"
#include "AIMacros.h"
#include "AI_Erm.h"
#include "Convert.h"
#include "gsparam.h" 
#include "Array.h"
#include "dsgmem.h"
 
/*XB*/
#if defined(AI_USE_SCRIPT)
/*End XB*/

extern void fn_vInitDsgVarValue(void *p_MyVarAddr,tdeDsgVarTypeId eDsgVarTypeId,char * szParams[]);

void fn_vInitArray(struct tdstArray_ *p_stArray,enum tdeDsgVarTypeId_ eDsgVarType,unsigned char ucNbElements,char *szParams[])
{
	M_ARRAY_SIZE(p_stArray)=ucNbElements;
	M_ARRAY_TYPE(p_stArray)=eDsgVarType;
	M_ARRAY_CLEAR(p_stArray);
 
	if (szParams!=NULL)
	{
		char ucIndex=0;
		char *p_MyVarAddr;
		char **ptr=szParams+1;
 
		while(ptr[2]!=NULL)
		{
			if (ucIndex<ucNbElements)
			{
				p_MyVarAddr=(char*) M_ARRAY_ELEMENT(p_stArray,ucIndex);
 
				fn_vInitDsgVarValue(p_MyVarAddr,eDsgVarType,ptr);
 
				if (eDsgVarType==eDsgVarType_Vector) 
				{
					/*ptr+=3;*/
					ptr++;
					if (ptr[2]!=NULL) ptr++;
					if (ptr[2]!=NULL) ptr++;
				}
				else
				{
					ptr++;
				}
				ucIndex++;
			}
			else
			{
				break;
			}
		}
	}
 
}
/*XB*/
#endif /* AI_USE_SCRIPT */
/*End XB*/
