
pro klik,nomark=nomark, bin=bin, color=color, xsave, ysave
;+
;NAME:
;	klik
;PURPOSE:
;	To return pixel location.
;CALLING SEQUENCE:
;	klik 
;	klik, /nomark, bin=4, color=1
;       klik, xsave, ysave
;INPUT:
;	None
;OPTIONAL INPUT
;	nomark	- If present, the location on the image which 
;		  is selected is NOT marked (default is to mark it)
;	bin	- The rebin size used to display the image
;	color	- The color used to mark the click
;OUTPUT:
;       x and y pixel coordinates, printed to terminal.
;OPTIONAL OUTPUT:
;	xsave, ysave - vectors of the x and y values of clicked points.
;HISTORY:
;	Written 25-APR-92 BY L. Acton
;	Color added 3-May-1992
;       Outputs added 10-Dec-94 (HSH)
;	Corrected xsave, ysave to include division by bin.
;-
;
if n_elements(bin) eq 0 then bin=1
if n_elements(color) eq 0 then color=255
;
;
qdone = 0
while not qdone do begin
;    print, '* Use left button to mark the center
;    print, '* Use the right button to exit'

    wait, 0.3
    cursor, x, y, /device
    button = !err
    case button of
	1: begin	;left button
		print, 'Center location: ', x/bin, y/bin
		x0 = x-(bin/2)
		y0 = y-(bin/2)
		x1 = x+(bin/2)
		y1 = y+(bin/2)
		xa=x0
		xb=x1
		ya=y0
		yb=y1
                if n_elements(xsave) eq 0 then xsave = x/bin $
			 else xsave = [xsave,x/bin]
                if n_elements(ysave) eq 0 then ysave = y/bin $
			 else ysave = [ysave,y/bin]
	   end
	4: begin	;right button
	   end
    endcase
    ;
    if (button ne 4) then begin
      if (not keyword_set(nomark)) then begin
         plots, [x-5,x-2],[y,y],/device,color=color
         plots, [x,x],[y+2,y+5],/device,color=color
      endif
    end
    if (button eq 4) then qdone = 1
    end
;
end


