DECLARE CONSTANT CMB_InsType				AS QUANTITY 6001
DECLARE CONSTANT CMB_Instrument				AS QUANTITY 6003

DECLARE CONSTANT iFLD_SYMBOL 	AS QUANTITY 0
DECLARE CONSTANT iFLD_TYPE 		AS QUANTITY 8

DECLARE CONSTANT OBJ_POOL_INST 	AS QUANTITY 1

DECLARE VARIABLE s_SelectedInstType		AS TEXT 	100

DECLARE CONSTANT DATA_POOL_EQT_INST 	AS QUANTITY 19

PROCEDURE LoadSymbolsOfDefinition
        DECLARE PARAMETER sDefID AS TEXT        DO
{
	CALL OnChangeCombo "", "", [sDefID], 0, CMB_InsType ; 
}

###############################################################################
PROCEDURE OnInitForm DO
{	
	[s_SelectedInstType] := ""; 
}

PROCEDURE OnChangeCombo
        DECLARE PARAMETER sGroupName as TEXT
        DECLARE PARAMETER sFieldName as TEXT
        DECLARE PARAMETER sVal as TEXT
        DECLARE PARAMETER nCurSel as QUANTITY
        DECLARE PARAMETER nControlID as QUANTITY DO
{
	IF ([nControlID] = CMB_InsType) DO
  	{  		
  				IF ( [sVal] != [s_SelectedInstType] ) DO
		{
			CALL PopulateInstrumentList [sVal] ; 
		}
  	}
}

PROCEDURE PopulateInstrumentListOnInstChange
       DECLARE PARAMETER sSelectedInstType as TEXT DO
{
	DECLARE VARIABLE sInst AS TEXT 100
	[sInst] := GetFieldValue1(CMB_Instrument);
	
	IF ( [sSelectedInstType] != [s_SelectedInstType] ) DO
	{
		CALL PopulateInstrumentList [sSelectedInstType];
		
		SetFieldValue1(CMB_Instrument,[sInst]);
		SetFieldValue1(CMB_InsType,[sSelectedInstType]);
	}
}

PROCEDURE PopulateInstrumentList
        DECLARE PARAMETER sSelectedInstType as TEXT DO
{
			
	RemoveListEntry2(CMB_Instrument,"");
	[s_SelectedInstType] := [sSelectedInstType] ;
	
	IF ([sSelectedInstType] = "Equity") DO
	{			  
		SetControlPool(CMB_Instrument, DATA_POOL_EQT_INST);
		RETURN
	} 
	
	DECLARE VARIABLE nCount AS QUANTITY
	DECLARE VARIABLE nIndex AS QUANTITY
	DECLARE VARIABLE sKey AS TEXT 100
	DECLARE VARIABLE sFieldVal AS TEXT 100

	RemoveListEntry2(CMB_Instrument,"");
					
	[nCount] := GetObjPoolItemCount(OBJ_POOL_INST);
	[nIndex] := 0;
	[sKey] := "";
	[sFieldVal] := "";	
	
	WHILE ([nIndex] < [nCount]) DO
	{		
		[sKey] := GetObjPoolItemKey(OBJ_POOL_INST,[nIndex]);
		[sFieldVal] := GetObjPoolItemVal(OBJ_POOL_INST,[sKey],iFLD_TYPE);
		IF ([sFieldVal] = [sSelectedInstType]) DO
		{			  
			[sFieldVal] := GetObjPoolItemVal(OBJ_POOL_INST,[sKey],iFLD_SYMBOL);
			AddListEntry3(CMB_Instrument,[sFieldVal]);		
		}
		
		[nIndex] := ([nIndex] + 1);
	}
		
}



