Viewing contents of file '../idllib/astron/contrib/varosi/code/allpro/analysis_select.pro'
pro analysis_select, change
;+
; Select mosaic images for Math_mosaics & Analysis.
; Frank Varosi NASA/Goddard 1991.
;-
   common mosaic_array, mosaics, mosaic_specs, mosaic_infos
   common menus, menu_window
   common math_mosaics, math_List, math_images, math_imscaled

	Nmath = N_struct( math_List )
	imos=0
	change=0

	if (Nmath GT 0) then begin

		print,"Currently in Math List :"
		names = "           " + math_List.name
		for i=0,Nmath-1 do print, names(i)
		wait,0.5

		menu = ["Currently in Math List :"	,$
			" "				,$
			math_List.name			,$
			" "				,$
			"Do you want to..."		,$
			" "				,$
			"  use current mosaics? or..."	,$
			" "				,$
			"  get more mosaics? or..."	,$
			" "				,$
			"  get all new mosaics?"	]

		Litem = N_elements( menu )-1
	MENU:	select = wmenu( menu, INIT=Litem-2, TIT=Litem-6 )

		request = menu(select>0)
		task = next_word( request )

		if (task EQ "use") then return
		if (task NE "get") then goto,MENU

		if next_word( request ) EQ "all" then begin
			ok = yes_no_menu( "really replace current mosaics?",/B )
			if (ok) then begin
				math_Lsave = math_List
				math_List = 0
				math_images = 0
				math_imscaled = 0
			  endif else  goto,MENU
		   endif
	   endif

	if N_struct( math_List ) GT 1 then group = max( math_List.group )+1 $
	else if N_struct( math_List ) EQ 1 then group = math_List(0).group $
					   else group = 0

	if N_struct( mosaic_specs ) LE 0 then $
				mosaic_specs = mosaic_struct( 9, TYPE="spec" )
SELECT:
	imos = select_mosaic( "for Math", mosaic_specs.name,/RESTORE,IN=imos+1 )

	if (imos LT 0) then return

	mos_name = mosaic_specs(imos).name
	print," selected: ",mos_name

	Nmath = N_struct( math_List )
	if (Nmath LE 0) then match=0 else $
			w = where( [math_List.name] EQ mos_name, match )

	if (match GE 1) then begin

		print," already in Math List, using it as is..."
		wait,0.5

	  endif else begin

		analysis_addmos, imos, Nmath, TEMPLATE=math_Lsave
		math_List(Nmath).group = group
		change = 1
	   endelse

	goto,SELECT
end