;+ ***********************************************************************
; NAME:
;	GET_OLDWINDOW
;
; PURPOSE:
;       Cette procedure renvoie la derniere fenetre du module utilisee
;       fct a utiliser pour recuperer une fenetre ou on veut 
;       faire un noerase                                         
;
; CATEGORY:
;	NRH1 General
;
; CALLING SEQUENCE:
;	Indice = GET_OLDWINDOW,ideb,ifin
;
; INPUTS:
;	IDEB	Indice de debut
;	IFIN	indice de fin
;	
; KEYWORD PARAMETERS:
;	Non
;
; OUTPUTS:
;	INDICE	indice de la fenetre a utiliser
;
; RESTRICTIONS:
;	La signification de IDEB et IFIN est a preciser
;
; MODIFICATION HISTORY: (bonmartin@obspm.fr)
;	17/11/98	Adapte du logiciel XHELIO (module window.pro) (JB)
;-*******************************************************************

;* ------------------------------------------------------------- *

;* --------------------------------------------------------------*
   

FUNCTION get_oldwindow,ideb,ifin
common NRH1_HELIO,mainstruct

oldwin = where(mainstruct.window(ideb:ifin) EQ 1,count)
IF (count EQ 0) THEN oldwin = ideb ELSE oldwin = oldwin(0) + ideb
; oldwin fenetre a utiliser

oldwin = oldwin - 1
IF oldwin LT ideb THEN oldwin = ifin
;NEWWSET,oldwin
	  DEVICE,window_state = openwin
		IF Openwin(oldwin) EQ 1 THEN WSET,oldwin ELSE BEGIN
		  IF (mainstruct.laser EQ 0) THEN $
		  WINDOW,oldwin,XSIZE=mainstruct.winxsize, $
				YSIZE=mainstruct.winysize
		ENDELSE
; on se place sur la fenetre precedant celle a utiliser

; si affichage multiple on se place dans le dernier trace
IF ((!P.MULTI(1)+!P.MULTI(2)) NE 0) THEN BEGIN
   !P.MULTI(0)=!P.MULTI(0)+1
ENDIF 

RETURN,oldwin
END
