//BEGIN FS 10/9/98
/*----------------------------------------------------------------------
 *  Description: callback for .CSB sript file
 *----------------------------------------------------------------------
 *  Input:
 *  Output:
 *----------------------------------------------------------------------
 *  Author: FS
 *  Creation date:10/9/98
 *  Modif date:
 *----------------------------------------------------------------------*/
int TSN_Event::LoadCSB_File( LDT_tdst_Link *pLink )
{
	LDT_tdeParseResult result=ParseResult_BeginSection;
	char *szSectionName;

	result=LDT_GetNextEntry();
	while( result==ParseResult_BeginSection )
	{
		szSectionName=LDT_szGetEntryName();
		switch (*(long*)(szSectionName+5/*"SndEv"*/))
		{
		case 'etne': //"SndEventE"
			LDT_LoadSection(NULL);
			break;
		default:
			LDT_SkipSection();
		}//end switch
	    result=LDT_GetNextEntry();
	}//end while
	return 0;
}
//END FS 10/9/98

//BEGIN FS 10/5/98
/*----------------------------------------------------------------------
 *  Description: callback for SndEventE section from .CSB sript file
 *----------------------------------------------------------------------
 *  Input:
 *  Output:
 *----------------------------------------------------------------------
 *  Author: FS
 *  Creation date:10/5/98
 *  Modif date:
 *----------------------------------------------------------------------*/
int TSN_Event::LoadCSB_SndEventE( LDT_tdst_Link *pLink )
{
	LDT_tdeParseResult result=ParseResult_BeginSection;
	char *szEntryName;

	TSN_Event *pEvent;
	CString csName,csTemp;
	int iPos;
	tdeMissingCriteria eAns;
    char szEntry1[MAX_PATH];
    int iLen;

//	unsigned long* pOpenSection;
//	SCR_tdst_Sect_Open *pOpenSection;
	SND_tdstBlockEvent *pEngineEvent;

	//Working for BeginSection
	// Create event:
	pEvent=new TSN_Event();
	pLink->pObject=pEvent;
	g_poSNDEDITInterface->m_EdiEventList.AddTail(pEvent);

	// Transform the SndEventE in SndEventM:
	iLen=LDT_ComputeSectionName(pLink,szEntry1);
    csName = szEntry1+iLen;
	iPos=csName.Find("sndevente");

	if (iPos!=-1) 
    {
        csName.SetAt(iPos+8,'m');
     }
	// set the engine event pointer if event is loaded:
	//pEngineEvent=(SND_tdstBlockEvent*)LDT_LoadSection((char*)(LPCTSTR)csName);
    LDT_tdst_Link *pLink1 = LDT_GetLink( (char*)(LPCTSTR)csName );
    if (pLink1!=NULL)
    {
        pEngineEvent=(SND_tdstBlockEvent*)pLink1->pObject;
//		pEngineEvent=(SND_tdstBlockEvent *)SCR_M_ul_RdL0_ExtractLongValue(&pOpenSection->stSectionValues,0);
		if( pEngineEvent !=NULL )
        {
            if (pEngineEvent!=pEvent->m_pEngineEvent)
		    {
			    pEvent->fn_vUpdateData(pEngineEvent);
			    pEvent->m_pEngineEvent=pEngineEvent;
		    }
		    pEvent->SetAvailable(TRUE);
        }
	}	
	pEvent->SetReferencedSectionName(csName);

	//Working for entries
	result=LDT_GetNextEntry();
	while( result!=ParseResult_EndSection )
	{
		szEntryName=LDT_szGetEntryName();
		switch (*(long*)(szEntryName))
		{
		case 'NteS': //"SetName"
			// Compute csb name, without the '.csb' extension:
			csName=pLink->szFile;
			csTemp=csName.Left(csName.GetLength()-4);
			// crate event name as registered in name list:
			csName.Format("SND_%s_%s",LDT_szGetParam(1),csTemp);
			eAns=pEvent->fn_eRename(csName);
			if (eAns!=E_mc_None)
			{
				csTemp.Format("Sound Editor Event Creation error: Name SND_%s incorrect(already exists or syntax incorrect)!",csName);
				AfxMessageBox(csTemp);
			}
			// We have the event group's name: no need to continue this section analysis:
			while (LDT_GetNextEntry()!=ParseResult_EndSection);
			return 0;
		}//end switch
    	result=LDT_GetNextEntry();
	}//end while
	return 0;
}
//END FS 10/5/98
