;+
; Project     :	SOLAR-B - EIS
;
; Name        :	EIS_CPT_ADD
;
; Purpose     :	Adds 2nd argument to 1st argument array.
;
; Explanation : Concatenates the second array to the first or equates
;               the first to the second if the first array has not yet been initialized.
;               If second array not defined then returns.
;               Using this routine allows more efficient methods to be implemented in the future
;               should efficiency become an issue.
;
; Use         :	< eis_cpt_add, array, new >
;
; Inputs      :	array : ARR[] existing array
;               new   : ARR[] or SCALAR new data
;
; Opt. Inputs : None.
;
; Outputs     : array : ARR[] updated array
;
; Opt. Outputs:	None.
;
; Keywords    : PRE : add new data at beginning rather than end.
;
; Calls       : None.
;
; Common      :	None.
;
; Restrictions:	None.
;
; Side effects:	None.
;
; Category    :	EIS_CPT.
;
; Prev. Hist. :	None.
;
; Written     :	Martin Carter RAL 06/12/04
;
; Modified    : Version 0.1, 18/01/05, MKC
;                 Renamed routine from eis cpt add bytes and generalized to any array.
;               Version 0.2, 22/05/06, MKC
;                 For compatibility with IDL vs 6.2 (keyword_set([0])=1 previously),
;                 removed use of external array=0 to trigger initialization of array.
;
; Version     :	0.2, 22/05/06
;-
;**********************************************************

PRO eis_cpt_add, array, new, PRE=pre

  ; check if new defined before proceeding

  IF N_ELEMENTS(new) EQ 0 THEN RETURN

  ; check if array set up yet
  ; NB array must actually be an array rather than a scalar

  IF N_ELEMENTS(array) EQ 0 THEN BEGIN

    array = [new]

  ENDIF ELSE BEGIN

    IF KEYWORD_SET(pre) THEN array = [new, array] ELSE  array = [array, new]

  ENDELSE

END





