FUNCTION CNVRT_ABC, abc
;+
; NAME:
;	CNVRT_ABC
;
; PURPOSE:
;	This function converts the LEB activity buffer codes to a string.
;
; CATEGORY:
;	LASCO PACKETS
;
; CALLING SEQUENCE:
;	Result = CNVRT_ABC (Abc)
;
; INPUTS:
;	Abc:	An integer giving the code value
;
; OPTIONAL INPUTS:
;	None
;
; KEYWORD PARAMETERS:
;	None
;
; OUTPUTS:
;	This function returns a string giving the conversion of the activity 
;       buffer code value.
;
; OPTIONAL OUTPUTS:
;	None
;
; COMMON BLOCKS:
;       abc_common:  Used to determine if the conversions have been read in
;		     and to hold the conversion table for subsequent calls.
;
; SIDE EFFECTS:
;	None
;
; RESTRICTIONS:
;	None
;
; PROCEDURE:
;	This routine reads in the conversion file (abc.inc) the first time
;	it is called.  It then searches the activity buffer codes for a
;	match of the input code.
;
; EXAMPLE:
;
; MODIFICATION HISTORY:
;       1/13/94  SEP  Changed to read buffer numbers and messages
;       7/26/01  DW   Modified abc.inc and changed to handle numbers properly
;
;
;	@(#)cnvrt_abc.pro	1.3 11/05/01 LASCO IDL LIBRARY
;-
;
;
COMMON abc_common, abcread,     $;** 1 if abc.inc has been read
                   abcindex,    $;** integer array of activity buffer indices
                   abcstring     ;** string array of activity buffer messages

    sz = SIZE(abcread)
    IF (sz(1) EQ 0) THEN BEGIN   ;** read data from input file
        PRINT, "READING FROM abc.inc"
        file = getenv_slash('NRL_LIB')+'lasco/packets/abc.inc'
        READFMT, file, 'A39,I5,A80', junk, ind, str, /SILENT
        abcindex = ind
        abcstring = str
        abcread = 1
    ENDIF

    index = WHERE(abcindex EQ abc,count)
    IF (count eq 0 and abc GT 8192 and abc LE 65534l) THEN BEGIN
    ; PRINT,"Number ",abc - 8192
    retstring = strtrim(string(abc-8192),2)
    RETURN,retstring
    ENDIF
    sz = SIZE(index)
    IF (sz(1) GT 1) THEN BEGIN
        PRINT, "%CNVRT_ABC: multiple occurances of index ", abc, " in abc.inc, using first occurance."
    ENDIF
    index = index(0)

    IF (index LT 0) THEN $
        RETURN, '' $             ;** NO message found for given abc number
    ELSE BEGIN
        retstring = abcstring(index)
        retstring = STRTRIM(retstring, 2)
        slen = STRLEN(retstring)
        retstring = STRMID(retstring,3,slen-6)
        RETURN, retstring
    ENDELSE

END
