PRO prestore,qlwid,datax,datay,scrnx,scrny,jx,jy,plot_number=plot_number
  common wstore,D,P,Nn,Xx,Yy,dataxx,datayy
  
  On_Error,2
  
  IF N_elements(qlwid) ne 1 THEN $
    message,'Use: PRESTORE,QLWID [,datax,datay,scrnx,scrny]'
  
  IF qlwid lt 0 or qlwid gt N_elements(d)-1 THEN $
      message,'QLWID must be <0,...,'+trim(N_elements(d)-1)+'>'
  
  i = qlwid
  
;!D = D(i)
  
  set_plot,D(i).name
  
  IF (D(i).flags and 256) gt 0 THEN BEGIN
      DEVICE,window_state=open_window
      IF D(i).window lt 0 or open_window(D(i).window>0) eq 0 THEN BEGIN
      plot_number = 'Closed Window'
      return
      END
  EndIF
  
  IF (!D.flags and 256) gt 0 THEN SetWindow,D(i).window
  
  !P = P(i)
  !X = Xx(i)
  !Y = Yy(i)
  datax = dataxx(i) &  datay = datayy(i)
  scrnx = !P.clip(2)-!P.clip(0)+1 &  scrny = !P.clip(3)-!P.clip(1)+1
  jx = !P.clip(0) & jy = !P.clip(1)
  plot_number = Nn(i)
END