	FUNCTION fndfld, idx, tag
;	---------------------------------------------------------------
;+							21-Jan-92
;	NAME: fndfld
;	
;	Purpose: given an array of structures, it finds the tag and 
;		returns an array of the requested tag.
;
;	Input:
;		idx	an array of structures
;		tag	requested tag
;	Returned:
;		an array of the requested tag
;	HISTORY:
;		written, 16-Jan-92, GAL
;		updated for either .gen or .sxt nested path
;-
;	---------------------------------------------------------------

	siz = size(idx)				;check data-type

	typ = siz( siz(0)+1 )
	IF (typ eq 8) THEN BEGIN		;it is a STRUCTURE-type
	  tags = tag_names(idx)			;look at tags
	  IF (tags(0) eq 'GEN') THEN BEGIN	;sxt index structure
	    z = EXECUTE('ret= idx.sxt.' + tag)	;define ret array
	    IF (z ne 1) THEN BEGIN 	;execute error
	      z = execute('ret= idx.gen.' + tag)
	    ENDIF
	  ENDIF ELSE BEGIN			;assume roadmap or obs 
	    z = EXECUTE('ret= idx.' + tag)
	  ENDELSE
	  IF (N_elements(z) ne 0 ) THEN BEGIN	;z is defined
	    IF (z ne 1) THEN BEGIN	;EXECUTE error
	      PRINT, '***Execute ERROR in fndfld***'
	      ret= -1			;set error flag
	      RETURN, ret
	    ENDIF
	  ENDIF
	ENDIF ELSE BEGIN			;not a structure
	  ret = idx
	ENDELSE

	RETURN, ret
	END
