;***
;###############################################################################
;#                                                                             #
;# Procedure name  : QL_SELECTFMT                                              #
;#                                                                             #
;# Author          : Nicolas MORISSET                                          #
;# Language        : IDL                                                       #
;# Purpose         : Find the index of the current image or profile            #
;# Creation date   : 10-FEB-1994                                               #
;# Update date     : 16-03-94	E.PETIT		Remove trace		       #
;# External modules: None                                                      #
;#                                                                             #
;# Call sequence   :                                                           #
;#                   QL_SELECTFMT,mode                                         #
;# Arguments       :                                                           #
;#                   mode --> Input variable                                   #
;#                            Object : It can be two values.                   #
;#                                     IMAGE   = 0                             #
;#                                     PROFILE = 1                             #
;# Description     :                                                           #
;#                   This index permits to obtain the feature of the current   #
;#               image or profile.                                             #
;#                                                                             #
;###############################################################################
;***


PRO QL_SELECTFMT,mode

;===============================================================================
;                           Common Block in use
;===============================================================================

  COMMON format_com
  COMMON const_com
  COMMON curr_data_i_com
  COMMON curr_data_p_com


;===============================================================================
;                              Initialization
;===============================================================================

found=0
i=0
IF (mode EQ IMAGE) THEN BEGIN
   image_type=curr_header_i.SSTYPIMG
ENDIF ELSE BEGIN
   image_type=curr_header_p.SSTYPIMG
ENDELSE

;===============================================================================
;                               Processing
;===============================================================================

WHILE ((i LE N_ELEMENTS(format_lst)-1) AND (found EQ 0)) DO BEGIN
    IF (format_lst(i).number EQ image_type) THEN BEGIN
      selected_format = i
      found=1
    ENDIF
    i=i+1
ENDWHILE

END
