	PRO CkTimeNkey, fileNa, utime, ukey, userTimes=userTim, $
			key=key, ntimes = ntimes
;	----------------------------------------------------------
;+						 17-Mar-92
;	Name:
;		CkTimeNkey
;	Purpose:
;		Check for the presence of either time or key to
;		define the start and end times for data extraction
;		and to set time and key flags (utime and ukey).
;	CALLING SEQUENCE:
;		CkTimeNkey, fileNa, utime, ukey, [userTime=userTim,
;			key=key, ntimes=ntimes]
;	Input/Keyword:
;		fileNa		observing log file name
;		userTim		2-element structured var. with 
;				start and stop times.
;		key		string var. with a list of search
;				items, operators, and values.
;	Output:
;		userTim		updated start n stop for "key" only
;				request.
;		utime		flag =1 if usertim is present, 0 if not
;		ukey		flag =1 if key is present, 0 if not.
;		ntimes		number of times specified by user.
;	History:
;		written 20-May-91 by GAL
;		modified 26-July-91, to use Make_Str(ucture) to create
;		time-date logical data-type.
;		Oct 91???, if time and key are not defined read whole file
;		17-Mar-92, corrected a bug with last_day load into 
;			the returned userTim.
;-
;	-------------------------------------------------------------

	utime = 0	;initialize time flag as NOT present
	ukey  = 0 	;initialize key flag as NOT present

	IF (KeyWord_Set(userTim) NE 0) THEN BEGIN   ;times are defined
	  utime = 1
	  ntimes = SIZE(userTim)	;ck number of input times =2
	  ntimes = ntimes(ntimes(0)) 	;n elements
	ENDIF
	IF (KeyWord_Set(key) NE 0) THEN BEGIN	;key is defined
	  ukey = 1
	ENDIF

;	Check the odd cases the combination of utime and ukey:
	IF (ukey eq 0) AND (utime eq 0) THEN BEGIN	;return all data
	  Print, '**** NO Requested time or Key ****'
	  Print, '**** Returning all requested data...        ****'
	  RD_fHeader, fileNa, fHeader, ndset	;get 1st and last times
	  timeStr= "{jtime, time:LONG(0), day:FIX(0)}"
	  userTim = Make_STR(timeStr)
	  userTim = REPLICATE(userTim, 2)	;2-elements
	  userTim(0).time = fHeader.first_time
	  userTim(0).day  = fHeader.first_day
	  userTim(1).time = fHeader.last_time
	  userTim(1).day  = fHeader.last_day
	  RETURN
	END
	
	IF (ukey eq 1) AND (utime eq 0) THEN BEGIN	;key search only
	  RD_fHeader, fileNa, fHeader, ndset	;get 1st and last times
	  timeStr= "{jtime, time:LONG(0), day:FIX(0)}"
	  userTim = Make_STR(timeStr)
	  userTim = REPLICATE(userTim, 2)	;2-elements
	  userTim(0).time = fHeader.first_time
	  userTim(0).day  = fHeader.first_day
	  userTim(1).time = fHeader.last_time
	  userTim(1).day  = fHeader.last_day
	ENDIF

	RETURN
	END
