PRO Files_1D, x, y, qualifier, dx, dy, file, $
	FILENAME = fileName, FILETYPE =fileType, $
	LINESTYLE = lineStyle, THICK = thick, $
	COLOR = color, SUBTITLE = subTitle, $
	TITLE = title, XTITLE = xTitle, YTITLE = yTitle, $
	TEXT = text, STATUS = status, USERSYM = userSym

;+
; NAME
;	One-dimensional files handling.
; PURPOSE
;	User Interface to read different types of files containing 
;	data for one-dimensional plots.
; CALLING SEQUENCE:
;	Files_1D, x, y [, qual, dx, dy, file ]
; INPUTS:
;	Variables have the same meaning as for the outputs, but
;	are used if a write option is selectioned.
; OUTPUTS:
;	x, y: values to be plotted. 
;	qualifier: the value given in the file by a number determined
;		in the mdisp format description, 
;		and translated for the system variable !psym.
;	dx, dy: values for the length of the error bars, they are 1D
;		if the bars are symmetric, otherwise 2D with
;		the second dimension = 2.
;	file: the name of the file read
; KEYWORDS:
;	FILENAME: if the filename is given, the interactive
;		part of the procedure is not used and the
;		file named "filename" is read.
;	FILETYPE: if the type is given, only those files are 
;		selected, and the file type is not asked 
;		interactively.
;	LINESTYLE: the style of the line used to connect points.
;		( Write default = 0 ). See !p.linestyle.
;	THICK: the line thickness (Write default = 0 ).
;		See !p.thick
;	TITLE, SUBTITLE, XTITLE, YTITLE: For the description
;		of the plot.
;	STATUS: "Done" if a file has been read, "Not Done" else.
; SIDE EFFECT:
;	Windows are opened, on vt300 the screen is erased.
;
; MODIFICATION HISTORY:
;	Creadted in June 1991 by A.Csillaghy
;	Modified, A.Csillaghy, for Wave 4 (mdispread), Nov. 92
;-

status = 'Not Done'
IF NOT Keyword_Set(FILENAME) THEN BEGIN

  lineStyle = 0
  thick = 0
  title = ''
  subtitle = ''
  xtitle = ''
  ytitle = ''
  text = '' 
  usersym = 0

  mainMenuLength=6
  mainMenu=StrArr(mainMenuLength)

  
  mainMenu(0)='Read: mdisp '
  mainMenu(1)='      columns'
  mainMenu(2)='Write: mdisp'
  mainMenu(3)='       columns'
  mainMenu(4)='Exit File Read'
  mainMenu(5)='Redisplay this Menu'

  choice=0
  index=1

  IF NOT Keyword_Set(FILETYPE) THEN fileType = ''

  REPEAT BEGIN
    
    choice=General_Menu(mainMenu, $
	'File Read: Choose File Type or Exit') 

   CASE 1 OF
    choice EQ 1 OR choice EQ 2: BEGIN
       IF choice EQ 1 THEN fileType  = 'mdisp' ELSE fileType = 'cols'
       fileName = FileMenu('*.'+fileType, /EXIT)
    END
    choice EQ 3 OR choice EQ 4: BEGIN
        LoadSelection, name, length, x, y, qual, dx, dy,  $
	color, lineStyle, thick, offset, overallQual,  userSym, $
	title, xTitle,  yTitle,  subtitle, text
        idxLst = IndGen( length(0) )
        IF choice EQ 3 THEN $
          MDispWrite, x(idxLst,0), y(idxLst,0), qual(idxLst,0), $
	dx(idxLst,0,*), dy(idxLst,0,*), $
	LINESTYLE = lineStyle(idxLst,0), $
	THICK = thick(0), $
	COLOR = color(0), SUBTITLE = subTitle(0), $
	TITLE = title(0), $
	XTITLE = xTitle(0), YTITLE = yTitle(0), $
	USERSYM = userSym(idxlst,0), STATUS = status, $
	/INTERACTIVE $
         ELSE $
           MDispWrite, x(idxLst,0), y(idxLst,0), qual(idxLst,0), $
	dx(idxLst,0,*), dy(idxLst,0,*), $
	LINESTYLE = lineStyle(0), $
	USERSYM = userSym(idxlst,0), STATUS = status, $
	/INTERACTIVE, /COLS
          RETURN
        END
      choice EQ mainMenuLength-1: RETURN
      ELSE: fileName = ''
    ENDCASE

  END UNTIL fileName NE ''

  file=fileName


ENDIF ELSE BEGIN
  file = fileName
  REPEAT BEGIN
    len = StrLen( fileName )
    fileType = StrTrim(StrMid(fileName,StrPos(file,'.')+1,len),2) 
    res = StrPos( filetype, '.' )
    IF res NE - 1 THEN fileName = fileType
  END UNTIL res EQ -1
ENDELSE

text = '' & xUnit = '' & yUnit = ''
CASE fileType OF
  'mdisp': MDispRead,file,x,y,qualifier,dx,dy, $
	LINESTYLE = lineStyle, THICK = thick, $
	COLOR = color, SUBTITLE = subTitle, $
	TITLE = title, XTITLE = xTitle, YTITLE = yTitle, $
	TEXT = text, USERSYM = userSym, STATUS = status
  'cols': Columns_Read, file, x, y, qualifier, dx, dy, $
	/INTERACTIVE, LINESTYLE = lineStyle, $
	USERSYM = userSym, STATUS = status
  ELSE: BEGIN
    Print,' This type is not known ...'
    RETURN
  END
ENDCASE

IF status EQ  "Done" THEN  $
  IF N_Elements(x) EQ 0 THEN x = FIndGen(N_Elements(y))

END

 