// EdIRIAWd.cpp : implementation file
//


int fn_iLoadAllWords( LDT_tdst_Link* pLink, CPA_EdIR_Dictionary **ppclDictionnnary )
{
  LDT_tdeParseResult result=ParseResult_BeginSection;
  char *sz;

	ASSERT(LDT_szGetParam(2)==NULL);
  ASSERT((sz=LDT_szGetParam(1))!=NULL);
	
  (*ppclDictionnnary)=new CPA_EdIR_Dictionary(atoi(sz),C_NB_LANGUAGES);

  while( result!=ParseResult_EndSection ) 
  {
  	result=LDT_GetNextEntry();
  	switch( result )
  	{
  	  case ParseResult_BeginSection: /* a subsection */
        LDT_LoadSection( NULL );
    }
  }

  return 0;
}

/****************************************************************************/

int fn_iLoadOneWord( LDT_tdst_Link *pLink, 
                    CPA_EdIR_Dictionary						*pclDictionnnary,
										td_fn_lFindIdFromScriptName	fn_lFindIdFromScriptName,
										td_fn_bIdIsValid						fn_bIdIsValid)
{
  LDT_tdeParseResult result=ParseResult_BeginSection;

	static CString	csScriptName=C_INVALID_SCRIPTNAME;
	static long			lId=C_INVALID_ID;
  static char szAction[MAX_PATH];

  strcpy( szAction, LDT_szGetSectionName() );
	csScriptName=szAction;
	lId=fn_lFindIdFromScriptName(szAction);

	ASSERT(M_SCRIPTNAME_IS_VALID(csScriptName));
	ASSERT(fn_bIdIsValid(lId));
	

  while( result!=ParseResult_EndSection ) 
  {
  	result=LDT_GetNextEntry();
  	switch( result )
  	{
  	  case ParseResult_Entry: /* an entry */
  	  {
  	    char  *sz;
        ASSERT(LDT_szGetParam(2)==NULL);
        ASSERT((sz=LDT_szGetParam(1))!=NULL);

        CString	csName=sz;
		    CString	csLanguage=LDT_szGetEntryName();
		    pclDictionnnary->m_fn_vAddEntry(csScriptName,lId,csName,csLanguage);
  	  }
  	}
  }

	csScriptName=C_INVALID_SCRIPTNAME;
	lId=C_INVALID_ID;

	return SCR_ERV_Anl_NormalReturn;
}


/****************************************************************************/
int fn_iLoadAllMetaActions(LDT_tdst_Link *pLink)
{
	return fn_iLoadAllWords(pLink, &gs_pclMetaActionDictionnary);
}


/****************************************************************************/
int fn_iLoadOneMetaAction(LDT_tdst_Link *pLink)
{
	return fn_iLoadOneWord(pLink,
                         gs_pclMetaActionDictionnary,
												 (td_fn_lFindIdFromScriptName *)fn_eFindMetaActionIdFromScriptName,
												 fn_bIsMetaActionIdValid);
}

/****************************************************************************/
int fn_iLoadAllProcedures(LDT_tdst_Link *pLink)
{
	return fn_iLoadAllWords(pLink, &gs_pclProcedureDictionnary);
}


/****************************************************************************/
int fn_iLoadOneProcedure(LDT_tdst_Link *pLink)
{
	return fn_iLoadOneWord(pLink,
                         gs_pclProcedureDictionnary,
												 (td_fn_lFindIdFromScriptName *)fn_eFindProcedureIdFromScriptName,
												 fn_bIsProcedureIdValid);
}

/****************************************************************************/
int fn_iLoadAllFunctions(LDT_tdst_Link *pLink)
{
	return fn_iLoadAllWords(pLink,&gs_pclFunctionDictionnary);
}

/****************************************************************************/
int fn_iLoadOneFunction(LDT_tdst_Link *pLink)
{
	return fn_iLoadOneWord(pLink,
                         gs_pclFunctionDictionnary,
												 (td_fn_lFindIdFromScriptName *)fn_eFindFunctionIdFromScriptName,
												 fn_bIsFunctionIdValid);
}


/****************************************************************************/
int fn_iLoadAllConditions(LDT_tdst_Link *pLink)
{
	return fn_iLoadAllWords(pLink, &gs_pclConditionDictionnary);
}

/****************************************************************************/
int fn_iLoadOneCondition(LDT_tdst_Link *pLink)
{
	return fn_iLoadOneWord(pLink,
                         gs_pclConditionDictionnary,
												 (td_fn_lFindIdFromScriptName *)fn_eFindConditionIdFromScriptName,
												 fn_bIsConditionIdValid);
}

/****************************************************************************/
int fn_iLoadAllKeyWords(LDT_tdst_Link *pLink)
{
	return fn_iLoadAllWords(pLink, &gs_pclKeyWordDictionnary);
}


/****************************************************************************/
int fn_iLoadOneKeyWord(LDT_tdst_Link *pLink)
{
	return fn_iLoadOneWord(pLink,
                         gs_pclKeyWordDictionnary,
												 (td_fn_lFindIdFromScriptName *)fn_eFindKeyWordIdFromScriptName,
												 fn_bIsKeyWordIdValid);
}

/****************************************************************************/
int fn_iLoadAllFields(LDT_tdst_Link *pLink)
{
	return fn_iLoadAllWords(pLink, &gs_pclFieldDictionnary);
}

/****************************************************************************/
int fn_iLoadOneField(LDT_tdst_Link *pLink)
{
	return fn_iLoadOneWord(pLink,
                         gs_pclFieldDictionnary,
												 (td_fn_lFindIdFromScriptName *)fn_eFindFieldIdFromScriptName,
												 fn_bIsFieldIdValid);
}

/****************************************************************************/
int fn_iLoadAllDsgVarTypes(LDT_tdst_Link *pLink)
{
	return fn_iLoadAllWords(pLink, &gs_pclDsgVarTypeDictionnary);
}

/****************************************************************************/
int fn_iLoadOneDsgVarType(LDT_tdst_Link *pLink)
{
	return fn_iLoadOneWord(pLink,
                         gs_pclDsgVarTypeDictionnary,
												 (td_fn_lFindIdFromScriptName *)fn_eFindDsgVarTypeIdFromScriptName,
												 fn_bIsDsgVarTypeIdValid);
}

/****************************************************************************/
int fn_iLoadAllDsgVarSaveTypes(LDT_tdst_Link *pLink)
{
	return fn_iLoadAllWords(pLink, &gs_pclDsgVarSaveTypeDictionnary);
}

/****************************************************************************/
int fn_iLoadOneDsgVarSaveType(LDT_tdst_Link *pLink)
{
	return fn_iLoadOneWord( pLink,
                         gs_pclDsgVarSaveTypeDictionnary,
												 (td_fn_lFindIdFromScriptName *)fn_ucFindSaveTypeNumberFromScriptName,
												 fn_bIsDsgVarSaveTypeIdValid);
}

/****************************************************************************/
int fn_iLoadAllDsgVarInitTypes(LDT_tdst_Link *pLink)
{
	return fn_iLoadAllWords(pLink, &gs_pclDsgVarInitTypeDictionnary);
}

/****************************************************************************/
int fn_iLoadOneDsgVarInitType(LDT_tdst_Link *pLink)
{
	return fn_iLoadOneWord(pLink,
                         gs_pclDsgVarInitTypeDictionnary,
												 (td_fn_lFindIdFromScriptName *)fn_ucFindInitTypeNumberFromScriptName,
												 fn_bIsDsgVarInitTypeIdValid);
}

