; docformat = 'rst' ; ; NAME: ; readBiblioEntry ; PURPOSE: ; Read a bibliographic entry, in key = value format. ; ;+ ; :Description: ; Read a bibliographic entry, in key = value format. ; ; :Categories: ; Bibliography ; ; :Params: ; file: in, required, type=string ; Path to a local file with bibliography information. ; ; :Keywords: ; ; :Returns: A structure with the bibliographic entries. Fields are:: ; ; :Examples: ; ; :Uses: ; ; :Author: ; B.Carry (OCA) ; ; :History: ; Change History:: ; Written in May 2016, B. Carry (OCA) ;- function readBiblioEntry, file ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--- TAG --- I -- Initialization And Input Verification -----------------------; ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; COMPILE_OPT hidden, idl2 ;--I.1-- Verify Input Syntax ----------------------------------------------------------------- if not keyword_set(file) then begin message, /ioError, 'Syntax error: bib = readBiblioEntry( file )' return, -1 endif ;--I.2-- Test File for Reading --------------------------------------------------------------- if not file_test(file,/read) then begin message, /ioError, 'Bibliography file cannot be found: '+strtrim(file,2) return, -2 endif ;--I.3-- Bibliographic Entry Structure ------------------------------------------------------- bib={id:'', ads:'', year:0, month:'', $ published:0, first:0, $ meeting:'', journal:'', volume:'', pages:'', $ author:'', title:'', link:{pdf:'',graph:''}, $ abstract:'', $ pop:{nea:0, mba:0, kbo:0}, $ sci:{shape:0, bin:0, compo:0, pop:0, orbit:0}, $ tech:{ao:0, lc:0, occ:0, astro:0, phot:0, spec:0, arch:0, vo:0}, $ so:{gaia:0, ephem:0}} ;--I.4-- Open the File ----------------------------------------------------------------------- openr, idIn, file, /get_lun line = '' while ~EoF(idIn) do begin ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--- TAG --- II -- Read the Bibliographic Entry -----------------------; ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--II.1-- Blind Read of the Each Line ------------------------------------------------------ readf, idIn, line ;--II.2-- Extract Key and Value ------------------------------------------------------------ split=strSplit( line,'=' ) key = strTrim( strmid(line,split[0],split[1]-split[0]-1), 2) val = strTrim( strmid(line,split[1],strLen(line)-split[1]), 2) ;--II.3-- Fill Output Structure ------------------------------------------------------------ case key of ;--II.3.1-- Typical Bibliographic Information 'ads': bib.ads = val 'year': bib.year = round(float(val)) 'month': bib.month = val 'published': bib.published = val 'first': bib.first = val 'journal': bib.journal = val 'meeting': bib.meeting = val 'volume': bib.volume = val 'pages': bib.pages = val 'author': bib.author = val 'title': bib.title = val ;--II.3.2-- Abstract and Links 'pdf': bib.link.pdf = val 'graph': bib.link.graph= val 'abstract': bib.abstract = val ;--II.3.3-- Population Keywords 'pop.nea': bib.pop.nea = round(float(val)) 'pop.mba': bib.pop.mba = round(float(val)) 'pop.kbo': bib.pop.kbo = round(float(val)) ;--II.3.4-- Topics Keywords 'sci.3d': bib.sci.shape = round(float(val)) 'sci.bin': bib.sci.bin = round(float(val)) 'sci.compo': bib.sci.compo = round(float(val)) 'sci.pop': bib.sci.pop = round(float(val)) 'sci.orbit': bib.sci.orbit = round(float(val)) ;--II.3.5-- Technique Keywords 'tech.ao': bib.tech.ao = round(float(val)) 'tech.lc': bib.tech.lc = round(float(val)) 'tech.occ': bib.tech.occ = round(float(val)) 'tech.astro':bib.tech.astro= round(float(val)) 'tech.phot': bib.tech.phot = round(float(val)) 'tech.spec': bib.tech.spec = round(float(val)) 'tech.arch': bib.tech.arch = round(float(val)) 'tech.vo': bib.tech.vo = round(float(val)) ;--II.3.6-- SNO Keywords 'so.gaia': bib.so.gaia = round(float(val)) 'so.ephem': bib.so.ephem = round(float(val)) ;--II.3.7-- Nespresso... what else? else: endcase endwhile ;--II.4-- Close File, Free Unit & Return --------------------------------------------------- close, idIn free_lun, idIn return, bib end