PRO Read_Values,x,y, NODISPLAY = noDisplay
 
;+
; NAME:
;	Read_Values
; PURPOSE:
;	Reads interactively a point on the screen
; CATEGORY:
;	User Interface
; CALLING SEQUENCE:
;	Read_Values [,x, y]
; OUTPUTS:
;	x,y: scalars, contains the x- and y-coordinate in data
;		units where the user clicked.
; KEYWORD:
;	/NODISPLAY: if present, the result is not shown on
;		the screen, but stored in the x,y variables.
; SIDE EFFECT:
;	On X terminals, uses windows.
;
; MODIFICATION HISTORY:
;	Created in June 1991 by A.Csillaghy
;-

  hms = GetHMS()

  result = StrArr(8)
  result(0) = 'Value of the clicked point: '
  result(6) = 'Press the left mouse button to read a new value '
  result(7) = 'Press the right button to stop reading values'

  IF !d.name EQ 'X' THEN BEGIN
    plotWin = !d.window
    winNr = WMesg( 'Click to the value you want to read' , $
	'Read Value', 500,200 )
    WSet, plotWin
  ENDIF

  REPEAT BEGIN

  
    IF !d.name NE 'X' THEN $
	 PTo,1,1,'Move the cursor to the point to read and '+ $
	'press <return>                .'

    IF !d.name EQ 'TEK' THEN  CursorVT, x, y $
    ELSE Cursor, x, y
    IF !d.name EQ 'X' THEN WDelete, winNr

    IF hms EQ 0 THEN $
      result(2)='               x= '+STRTRIM(STRING(x),2) $
    ELSE result(2)='               x= '+HMSConvert(x)
    result(3)='               y= '+STRTRIM(STRING(y),2)
  
  IF NOT Keyword_Set(NODISPLAY) THEN $
    IF !d.name EQ 'X' THEN BEGIN
      winNr = WMesg(result,'Read Value: Result',100,600)
      WSet,plotWin
      WShow, winNr
    ENDIF ELSE BEGIN
        Print, result(0) + StrTrim(result(2),2) + ' ' + $
          StrTrim(result(3),2)+ '.'
        Print,'<Return> for next reading, <E>xit otherwise'
        response = Get_Kbrd(1)
        IF response NE STRING(10B) THEN !err = 4
    ENDELSE
    
END UNTIL !err EQ 4

IF !d.name EQ 'X' THEN WDelete, winNr

END



