; $Id: insertstringinstringarray.pro,v 1.2 2005/01/24 17:34:51 azuah Exp $
;###############################################################################
;
; NAME:
;   insertStringInStringArray
;
; PURPOSE:
;   Insert a value into a sorted array at the appropriate location.
;
; CATEGORY:
;   Data Browser
;
; AUTHOR:
;   Richard Tumanjong Azuah
;   NIST Center for Neutron Research
;   100 Bureau Drive, Gaithersburg, MD 20899
;   United States
;   azuah@nist.gov; (301) 9755604
;   Feb, 2003
;
; LICENSE:
;  The software in this file is written by an employee of 
;  National Institute of Standards and Technology 
;  as part of the DAVE software project.
;
;  The DAVE software package is not subject to copyright protection
;  and is in the public domain. It should be considered as an
;  experimental neutron scattering data reduction, visualization, and
;  analysis system. As such, the authors assume no responsibility
;  whatsoever for its use, and make no guarantees, expressed or
;  implied, about its quality, reliability, or any other
;  characteristic. The use of certain trade names or commercial
;  products does not imply any endorsement of a particular product,
;  nor does it imply that the named product is necessarily the best
;  product for the stated purpose. We would appreciate acknowledgment
;  if the DAVE software is used of if the code in this file is
;  included in another product.
;
;###############################################################################



;===============================================================================
; insertStringInStringArray
;
; PURPOSE:
;   Insert a scalar string value into a string array at the specified
;   index location.
;
; PARAMETERS:
;   array [in|out; req] - the sorted array
;
;   value [in; req] - the string to be inserted.
;
;   index [in; req] - the index at which value should be inserted in array
;
pro insertStringInStringArray, array, value, index
len = n_elements(array)
case index of
    0: array = [value,array]
    else: begin
        if (index ge len -1) then begin
            array = [array,value]
            break
        endif
        array = [array[0:index-1],value,array[index:*]] 
    end
endcase
end
