;+
; Project     : SOHO - CDS     
;                   
; Name        : GET_MASK_ETC
;               
; Purpose     : Load all details from telemetry database.
;               
; Explanation : Reads the edited database file for EngA and EngB packets to
;               load the parameter name, packet offset, length, mask etc and
;               parameter description.  As a short cut, if an IDL save file
;               for this information exists in $CDS_ENG_DATA then use that
;               instead.
;               
; Use         : IDL> get_mask_etc, array
;    
; Inputs      : None
;               
; Opt. Inputs : None
;               
; Outputs     : array - strarr(18,n) where n is number of telemetry parameters.
;               
; Opt. Outputs: None
;               
; Keywords    : None
;
; Calls       : None
;
; Common      : None
;               
; Restrictions: Needs specific database file or IDL saveset.
;               
; Side effects: None
;               
; Category    : Telemetry
;               
; Prev. Hist. : None
;
; Written     : C D Pike, RAL, 26-Sep-94
;               
; Modified    : Upgraded to include all details of each telemetry parameter.
;                                         CDP, 22-Dec-94
;               Update to use CDS_ENG_DATA as the evar.  CDP, 27-Oct-95
;
;
; Version     : Version 2, 27-Oct-95
;-            

pro get_mask_etc, array

;
;  check evar is defined
;
if getenv('CDS_ENG_DATA') eq '' then begin
   bell
   print,'$CDS_ENG_DATA is not defined.'
   array = 0
   return
endif

;
;  check for save file
;
status = file_exist(concat_dir('$CDS_ENG_DATA','tm_dbase.save'))
if status then begin
   restore,concat_dir('$CDS_ENG_DATA','tm_dbase.save')
   return
endif

;
;  get database file
;
openr,lun,concat_dir('$CDS_ENG_DATA','new_database.txt'),/get_lun

;
;  create counters and storage
;
array = strarr(18,2000)
text = ' '
count = 0
fc = ' '
while not eof(lun) do begin
;
;read line
;
   while (fc ne 'A') and (fc ne 'B') do begin
      readf,lun,text
      fc = strmid(text,0,1)
   endwhile

;
;  chop off descriptor at end
;
   array(17,count) = strmid(text,115,40)

;
;  select non-descriptor items and split
;
   text = strmid(text,0,115)
   t = str_sep(text,' ')
   t = t(where(t ne ''))

;
;  load into output array
;
   n = n_elements(t)
   n = indgen(n)
   array(n,count) = t(n)

   count = count + 1
   fc = ' '
endwhile

;
;  release file
;
free_lun,lun

;
;  trim output
;
n = where(array(0,*) ne '')
array = array(*,n)

end

   
