;
; NAME:
;          GET_REPLY
;
; PURPOSE: This function uses widgets to prompt the user for a reply 
;          and returns the user input (string) to the calling program.
;
; CALLING SEQUENCE:
;          reply= GET_REPLY(massage)
;
; INPUTS:
;          message: A string directing the user as what kind of input to 
;                   provide. 
;
; OUTPUTS:
;         reply: User input (type string) is returned. 
;
; OPTIONAL OUTPUTS:
;          None
;
; MODIFICATION HISTORY:
;         Written by:  Ed Esfandiari, LASCO/NRL, April, 1999.
;
;
;         
pro get_reply_event,event
 common reply_data, user_reply,str

 WIDGET_CONTROL, event.id, GET_UVALUE=uval
 WIDGET_CONTROL, event.top, GET_UVALUE=struct   ; get structure from UVALUE

 case (uval) of
  'done': begin
            WIDGET_CONTROL, /DESTROY, struct.pbase
          end
  'reply': begin
            WIDGET_CONTROL, event.id ,GET_VALUE= user_reply 
            user_reply= user_reply(0)
          end
 endcase

end


function get_reply,message
    common reply_data, user_reply,str
   
    p=n_params()
    warn= ['A string message (instructing the user what kind',$
           'of input to provide) is required with this call.']
    if(p lt 1) then begin
      msg= widget_message(warn)
      return,'A message is required with this call.'
    end

    s=size(message)
    if(s(1) ne 7) then begin
      msg= widget_message(warn)
      return,'A message is required with this call.'
    end

    str=''
    user_reply= ''

;    pbase= widget_base(title='Enter a reply',xsize=280,ysize=90,xoffset=10,/frame)
    pbase= widget_base(title='Enter Reply',xoffset=10,yoffset=100,/frame)
    b1=widget_base(pbase,/ROW)
    colb1= widget_base(b1,/COLUMN)
    rowb1= widget_base(colb1,/ROW)
    txt= WIDGET_LABEL(rowb1,VALUE=' ')
    exit=  WIDGET_BUTTON(rowb1, VALUE='Done',UVALUE='done',/frame)
    txt= WIDGET_LABEL(rowb1,VALUE=' ')
    lab= WIDGET_LABEL(rowb1, VALUE=message)
    r2= widget_base(rowb1,/COL,/frame)
;    lab= WIDGET_LABEL(r2,VALUE="Enter Reply")
;    lab= WIDGET_LABEL(r2,VALUE=message)
    
    select= WIDGET_TEXT(r2,UVALUE='reply',VALUE='',xsize=15,/EDITABLE,/ALL_EVENTS,/scroll) 

    widget_control,pbase,/realize
    struct={pbase:pbase}
    widget_control,pbase, SET_UVALUE=struct
    xmanager,'get_reply',pbase,EVENT_HANDLER='get_reply_event',group_leader=group,$
             /MODAL

    return, user_reply

end
