	PRO LIST_OTHER_OBS, START, EEND, OBS, N_FOUND, ERRMSG=ERRMSG
;+
; Project     :	SOHO - CDS
;
; Name        :	LIST_OTHER_OBS
;
; Purpose     :	List plan for other observatories for given date range
;
; Explanation :	Extracts all the "Other_Obs" plan entries which intersect an
;		input time range.
;
; Use         :	LIST_OTHER_OBS, START, END, OBS, N_FOUND
;
; Inputs      :	START, END = The range of date/time values to use in searching
;			     the database.  Can be in any standard CDS time
;			     format.
;
; Opt. Inputs :	None.
;
; Outputs     :	OBS	= A structure variable containing the following tags
;			  for each planned observation:
;
;			STRUCT_TYPE  = The character string 'OTHER-OBS-LIST'.
;			TELESCOP     = The name of the telescope.
;			MNEMONIC     = The mnemonic for the telescope.
;			SCI_OBJ      = Science objective
;			SCI_SPEC     = Specific science objective
;			NOTES	     = Further notes about the observation
;			START_TIME   = Date/time of beginning of observation,
;				       in TAI format
;			END_TIME     = Date/time of end of observation, in TAI
;				       format
;			OBJECT	     = Code for object planned to be observed
;			OBJ_ID	     = Object identification
;			CMP_NO	     = Campaign number
;
;		N_FOUND	= Number of planned observations found.
;
; Opt. Outputs:	None.
;
; Keywords    :	
;       ERRMSG    = If defined and passed, then any error messages will be
;                   returned to the user in this parameter rather than
;                   depending on the MESSAGE routine in IDL.  If no errors are
;                   encountered, then a null string is returned.  In order to
;                   use this feature, ERRMSG must be defined first, e.g.
;
;                       ERRMSG = ''
;                       LIST_OTHER_OBS, ERRMSG=ERRMSG, ... 
;                       IF ERRMSG NE '' THEN ...
;
;
; Calls       :	DATATYPE, DBOPEN, DBFIND, DBEXT, DBCLOSE, TRIM
;
; Common      :	None.
;
; Restrictions:	None.
;
; Side effects:	If the number of planned observations found is zero, then the
;		output parameter OBS is not modified.
;
; Category    :	Planning, Database.
;
; Prev. Hist. :	None.
;
; Written     :	William Thompson, GSFC, 12 April 1995
;
; Modified    :	Version 1, William Thompson, GSFC, 12 April 1995
;
; Version     :	Version 1, 12 April 1995
;-
;
	ON_ERROR, 2
;
;  Check the number of parameters.
;
        IF N_PARAMS() LT 4 THEN BEGIN
           MESSAGE = 'Syntax:  LIST_OTHER_OBS, START, END, OBS, N_FOUND'
           IF N_ELEMENTS(ERRMSG) NE 0 THEN BEGIN
              ERRMSG = MESSAGE
              RETURN
           ENDIF ELSE MESSAGE, MESSAGE
        ENDIF
;
;  Check the input parameters.
;
	N_FOUND = 0
	IF N_ELEMENTS(START) NE 1 THEN BEGIN
           MESSAGE = 'START must be a scalar'
           IF N_ELEMENTS(ERRMSG) NE 0 THEN $
              ERRMSG = MESSAGE $
           ELSE MESSAGE, MESSAGE, /CONTINUE 
           GOTO, FINISH
	END ELSE IF N_ELEMENTS(EEND) NE 1 THEN BEGIN
           MESSAGE = 'END must be a scalar'
           IF N_ELEMENTS(ERRMSG) NE 0 THEN $
              ERRMSG = MESSAGE $
           ELSE MESSAGE, MESSAGE, /CONTINUE 
           GOTO, FINISH
	ENDIF
;
;  Convert the input dates to TAI format.
;
	IF DATATYPE(START,1) EQ 'Double' THEN TAI_START = START ELSE	$
		TAI_START = UTC2TAI(START)
	IF DATATYPE(EEND,1) EQ 'Double' THEN TAI_END = EEND ELSE	$
		TAI_END = UTC2TAI(EEND)
;
;  Open the science plan database.
;
	DBOPEN, 'other_obs'
;
;  Find all the entries in the requested time range.
;
	ENTRIES = DBFIND('END_TIME>' + TRIM(TAI_START,'(F15.3)') +	$
		',START_TIME<' + TRIM(TAI_END,'(F15.3)'), /SILENT)
	IF !ERR EQ 0 THEN BEGIN
		N_FOUND = 0
		GOTO, FINISH
	END ELSE BEGIN
		ENTRIES = ENTRIES(UNIQ(ENTRIES))
		N_FOUND = N_ELEMENTS(ENTRIES)
	ENDELSE
;
;  Extract the requested entries, sorted by start times.
;
	ENTRIES = DBSORT(ENTRIES,'start_time')
	DBEXT, ENTRIES, 'telescop,sci_obj,sci_spec,notes,start_time,end_time',$
		TELESCOP, SCI_OBJ, SCI_SPEC, NOTES, START_TIME, END_TIME
	DBEXT, ENTRIES, 'mnemonic,object,obj_id,cmp_no',	$
		MNEMONIC, OBJECT, OBJ_ID, CMP_NO
;
;  Remove any entries that only touch the requested time range.
;
	W = WHERE((END_TIME NE TAI_START) AND (START_TIME NE TAI_END), N_FOUND)
	IF N_FOUND EQ 0 THEN GOTO, FINISH
;
;  Define the structure that the data will be returned in.
;
	OBS = { STRUCT_TYPE: 'OTHER-OBS-LIST',	$
		MNEMONIC: 'String',	$
		TELESCOP: 'String',		$
		SCI_OBJ: 'String',	$
		SCI_SPEC: 'String',	$
		NOTES: 'String',	$
		START_TIME: 0.0D0,	$
		END_TIME: 0.0D0,	$
		OBJECT: 'String',	$
		OBJ_ID: 'String',	$
		CMP_NO: 0}
;
	IF N_FOUND EQ 1 THEN BEGIN
		OBS.MNEMONIC	= MNEMONIC(W(0))
		OBS.TELESCOP	= TELESCOP(W(0))
		OBS.SCI_OBJ	= SCI_OBJ(W(0))
		OBS.SCI_SPEC	= SCI_SPEC(W(0))
		OBS.NOTES	= NOTES(W(0))
		OBS.START_TIME	= START_TIME(W(0))
		OBS.END_TIME	= END_TIME(W(0))
		OBS.OBJECT	= OBJECT(W(0))
		OBS.OBJ_ID	= OBJ_ID(W(0))
		OBS.CMP_NO	= CMP_NO(W(0))
	END ELSE BEGIN
		OBS = REPLICATE(OBS, N_FOUND)
		OBS.MNEMONIC	= MNEMONIC(W)
		OBS.TELESCOP	= TELESCOP(W)
		OBS.SCI_OBJ	= SCI_OBJ(W)
		OBS.SCI_SPEC	= SCI_SPEC(W)
		OBS.NOTES	= NOTES(W)
		OBS.START_TIME	= START_TIME(W)
		OBS.END_TIME	= END_TIME(W)
		OBS.OBJECT	= OBJECT(W)
		OBS.OBJ_ID	= OBJ_ID(W)
		OBS.CMP_NO	= CMP_NO(W)
	ENDELSE
;
;  Close the database and return.
;
FINISH:
	DBCLOSE
;
	RETURN
	END
