Put the material/map for a texture in active slot in MatEditor

how to put the material in active slot for the selected texture!
how to put the map: also the material but this material should be opened till this map(if the map is instanced for the same material it would open the first map only), so that when I get back in levels I get to the root material witch contains this map!

i=0
			for row = 0 to (BitmapLister.table.rows.count - 1) where BitmapLister.table.rows.item[row].selected do 
				if ((i+=1)==1) then firstrow=row
			if i>1 then format "\tSelect one item\n"
			else
			(
                             MatEditor.Open()
                             setMeditMaterial medit.GetActiveMtlSlot() mat_col[firstrow]
			)
i=0
			for row = 0 to (BitmapLister.table.rows.count - 1) where BitmapLister.table.rows.item[row].selected do 
				if ((i+=1)==1) then firstrow=row
			if i>1 then format "\tSelect one item\n"
			else
			(
                             MatEditor.Open()
                             setMeditMaterial medit.GetActiveMtlSlot() mat_col[firstrow]
 
                            --?????? open map container   ??????--
 
			)