FUNCTION MSH, milli, DELIM = delim
;+ ***********************************************************************
; NAME:
;	MSH
;
; PURPOSE:
;	Cette fonction fait le codage de l'heure en MS en chaine ascii
;	HH:MN:SS:milsec . Le delimiteur est ':' .
;	Entre les secondes et les decimales de secondes on peut choisir 
;	un autre delimiteur ( '.' par ex) grace au keyword DELIM.
; CATEGORY:
;	CONVERSION
;
; CALLING SEQUENCE:
;	SH = msh (temps, DELIM = '.')
;
; INPUTS:
;	TEMPS	array temps en millisecondes.
;
; KEYWORD PARAMETERS:
;	DELIM: delimiteur entre secondes et decimales de secondes
;	par defaut ':'
;
; OUTPUTS:
;	SH	chaine contenant l'heure : HH:MN:SS:milsec
;
; EXAMPLE:
;	PRINT, MSH(380200)
; imprime l'heure
;
; MODIFICATION HISTORY:
;	Ecrit par:J Bonmartin
; a partir MSH$, seul changement de l'appel
;       modif A. Bouteille mai 1998 :
;	ajout du mot cle DELIM
;	accepte un tableau en entree avril 2001
;-*******************************************************************


IF N_Params() EQ 0 THEN BEGIN
   Print, ''
   Print, 'MSH: aucune valeur d''entree  ! '
   Print,''
   STOP
ENDIF
dlim=':'
if keyword_set(delim) then dlim = delim
;
; init.
;
sec=0l
heur=0l
minu=0l
seco=0l
ms=0l
milli=LONG(milli)
;
sec= milli/1000
heur=sec/3600
minu=sec/60-heur*60
seco=sec-(heur*3600+minu*60)
ms=milli-3600000*heur-60000*minu-seco*1000
nb=n_elements(milli)
if nb eq 1 then begin
    Chaine= STRCOMPRESS(STRING(heur,minu,seco,dlim,ms, $
		FORMAT='(i2.2,":",i2.2,":",i2.2,a1,i3.3)'),/REMOVE_ALL)
    RETURN, chaine
endif
if nb ne 1 then begin 
    chaine=strarr(nb)
    for i=0,nb-1 do begin
        Chaine(i)= STRCOMPRESS(STRING(heur(i),minu(i),seco(i),dlim,ms(i), $
		   FORMAT='(i2.2,":",i2.2,":",i2.2,a1,i3.3)'),/REMOVE_ALL)
    endfor
    RETURN, chaine
endif
END
;
;
;
;
;
;
;
;
;
