;+
;Project
;          Hinode/EIS
;
; Name
;          eis_eebp_initialize
;
; Purpose
;          Returns RESPONSE DB ID from solarb_science tag. Parses the
;          string to split up the comma-separated values
;          (eg: 'EEBP:2,XRTF:4') and matches the input type (eg: 'eebp').
;          If found, then splits that fragment to extract the ID number
;          (in this case: 2). Return this value. Otherwise, return zero.
;
; Notes
;          This response_id is passed into the event GUIS
;
; Category
;          Timeline planning
;          Response Studies
;
; Inpput
;          solarb_science - a string from tl.science_component
;          type           - one of 'eebp', 'eisf', 'xrtf', 'aece'
;
; Written
;          John Rainnie 26-Apr-2010
;
; Version
;          v0.0 JAR 01-01-2010
;               Blah
;
;-
;______________________________________________________________________________
FUNCTION eis_solarb_science_id , solarb_science , type

resp_id = 0L

isblank = is_blank(STRCOMPRESS(solarb_science,/REMOVE_ALL))
IF (isblank EQ 1) THEN RETURN , 0

; Check for 'EEBP:2' string, and get RESPONSE DB entry ID
split = STRSPLIT(solarb_science,',',/EXTRACT)
ffc   = STRMID(split,0,4)    ; get First Four Characters (ffc)
list  = WHERE(STRLOWCASE(ffc[*]) EQ STRLOWCASE(type) , ffc_count)

IF (ffc_count EQ 0) THEN RETURN , 0

; OK, got required fragment - now parse it to extract the ID part
line = STRCOMPRESS(split[list[0]] ,/REMOVE_ALL)
; Now extract the ID from 'EEBP:2'
split_1 = STRSPLIT(line,':',/EXTRACT)
resp_id = split_1[1]

; OK, got ID. Now check it exists.
; Open database
status     = eis_open_db(/RESPONSE)
constraint = STRJOIN(['ID',STRCOMPRESS(resp_id,/REMOVE)],'=',/SINGLE)
entry      = dbfind(constraint , /SILENT , count = count)
IF (count NE 1) THEN RETURN , 0

; To read the RESPONSE DB entry, use;
;struct = db_read_response_entry(id = resp_id)


RETURN , resp_id

END