;+
; NAME:
;	BCS_COMP
; PURPOSE:
;	Compresses real*4 data to 8-bit using BCS compression scheme
; CALLING SEQUENCE:  
;	dd = bcs_comp(data)
; INPUTS:
;	data	floating array of data
; OPTIONAL INPUTS:
;
; OUTPUTS:
;	dd	compressed 8-bit array
; OPTIONAL OUTPUTS:
;
; RESTRICTIONS:
;	Not sure that routine totally correct. Certainly recompresses 
;	correctly, but boundaries may be slightly out...
; PROCEDURE:
;
; MODIFICATION HISTORY:
;	RDB  25-Oct-92	Written
;       RDB   3-Sep-94  Allow scaler value to be decompressed
;       SLF   6-Jan-95  Rewrote to use table (.genx file) look up 
;
; Common Block:
;    bcs_comp_blk	store table after 1st read
;-
function  bcs_comp,data

common bcs_comp_blk, table

; read table on first call
compfile=concat_dir('$DIR_BCS_CAL','bcs_comp.genx')
if not file_exist(compfile) then begin
   message,/info,"Can't find compression table file: " + compfile
   message,/info,"Need to perform a Yohkoh SW upgrade..."
   return,-1
endif else if n_elements(table) eq 0 then restgen,file=compfile,table

return, table(data)				; table look up

end
