	PRO LIST_OBJECT, OBJECTS, N_FOUND, ERRMSG=ERRMSG
;+
; Project     :	SOHO - CDS
;
; Name        :	LIST_OBJECT
;
; Purpose     :	List the available SoHO object abbreviations.
;
; Explanation :	Extracts the names and abbreviations of all the SoHO object
;		classes.
;
; Use         :	LIST_OBJECT, OBJECTS, N_FOUND
;
; Inputs      :	None.
;
; Opt. Inputs :	None.
;
; Outputs     :	OBJECTS = A structure variable containing the following tags
;			  for each object:
;
;			OBJECT	    = Three letter object code
;			OBJECT_DESC = Expanded-out name of the object
;
;		N_FOUND	= Number of objects 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_OBJECT, ERRMSG=ERRMSG, ...
;                       IF ERRMSG NE '' THEN ...
;
;
; Calls       :	DATATYPE, DBOPEN, DB_INFO, DBEXT, DBCLOSE
;
; Common      :	Common block LIST_OBJECT contains the result of the first
;		time this routine is called.  Subsequent calls go to this
;		common block rather than directly to the file.
;
; Restrictions:	None.
;
; Side effects:	If the number of objects found is zero, then the output
;		parameter OBJECTS is not modified.
;
; Category    :	Planning, Database.
;
; Prev. Hist. :	None.
;
; Written     :	William Thompson, GSFC, 27 July 1994
;
; Modified    :	Version 1, William Thompson, GSFC, 27 July 1994
;               Version 2, Liyun Wang, GSFC/ARC, September 22, 1994
;                  Added the keyword ERRMSG.
;		Version 3, William Thompson, GSFC, 22 May 1995
;			Made output variable a named structure.
;		Version 4, William Thompson, GSFC, 14 August 1995
;			Added common block LIST_OBJECT.
;			Changed so that leading and trailing blanks are
;			trimmed.
;
; Version     :	Version 4, 14 August 1995
;-
;
	COMMON LIST_OBJECT, C_OBJECTS
	ON_ERROR, 2
;
;  Check the number of parameters.
;
        IF N_PARAMS() LT 2 THEN BEGIN
           MESSAGE = 'Syntax:  LIST_OBJECT, OBJECTS, N_FOUND'
           IF N_ELEMENTS(ERRMSG) NE 0 THEN BEGIN
              ERRMSG = MESSAGE
              RETURN
           ENDIF ELSE MESSAGE, MESSAGE
        ENDIF
;
;  If the routine has not already been called, then open the object database,
;  and extract all the entries.  Store them in the common block.
;
	IF N_ELEMENTS(C_OBJECTS) EQ 0 THEN BEGIN
		DBOPEN, 'object'
		N_FOUND = DB_INFO('entries','object')
		IF N_FOUND EQ 0 THEN BEGIN
			DBCLOSE
			GOTO, FINISH
		ENDIF
		ENTRIES = LINDGEN(N_FOUND) + 1
		DBEXT, ENTRIES, 'object,object_desc', OBJECT, OBJECT_DESC
		OBJECT = STRTRIM(OBJECT,2)
		OBJECT_DESC = STRTRIM(OBJECT_DESC,2)
		DBCLOSE
;
;  Define the structure that the data will be returned in.
;
		C_OBJECTS = {OBJ_DESC, OBJECT: 'String', OBJECT_DESC: 'String'}
;
		IF N_FOUND EQ 1 THEN BEGIN
			C_OBJECTS.OBJECT      = OBJECT(0)
			C_OBJECTS.OBJECT_DESC = OBJECT_DESC(0)
		END ELSE BEGIN
			C_OBJECTS = REPLICATE(C_OBJECTS, N_FOUND)
			C_OBJECTS.OBJECT      = OBJECT
			C_OBJECTS.OBJECT_DESC = OBJECT_DESC
		ENDELSE
	ENDIF
;
;  Return the information from the common block.
;
	OBJECTS = C_OBJECTS
	N_FOUND = N_ELEMENTS(C_OBJECTS)
;
FINISH:
	RETURN
	END
