;+
; Project     : SOHO - CDS     
;                   
; Name        : ASSIGN_NOCOPY
;               
; Purpose     : Move data from one variable to another, without copying.
;               
; Explanation : Under IDL Version 3.1 or later, the use of the NO_COPY keyword
;               in the call to WIDGET_CONTROL when setting or getting the
;               UVALUE of a widget provides a method of moving large amounts
;               of data from one variable to another without actually copying
;               it from one place to another.
;
;               From version 3.6 an on, handles are used instead of bases.
;               
; Use         : ASSIGN_NOCOPY,DESTINATION,SOURCE
;    
; Inputs      : SOURCE: The variable containing the data to move.
;               
; Opt. Inputs : None.
;               
; Outputs     : DESTINATION : A named variable to receive the contents of
;                             SOURCE.
;
;               
; Opt. Outputs: None.
;               
; Keywords    : None.
;
; Calls       : since_version, xalive
;
; Common      : None.
;               
; Restrictions: None.
;               
; Side effects: Creates a widget base.
;               
; Category    : Utility
;               
; Prev. Hist. : None.
;
; Written     : Stein Vidar Hagfors Haugan, ItA/UiO, 11-June-1994
;               
; Modified    : Version: 2, SVHH, 30 September 1996 Using SINCE_VERSION to
;                        determine whether NO_COPY can be used. Using handles
;                        from IDL v 3.6 and on.
;
; Version     : 2, 30 September 1996
;-            



PRO assign_nocopy,destination,source
  COMMON assign_nocopy_cache,sbase
  On_Error,2
  IF N_params()	lt 2 THEN message,'Use: ASSIGN_NOCOPY, DESTINATION, SOURCE'
  
  IF since_version('3.6') THEN BEGIN 
     IF N_elements(sbase) EQ 0 THEN sbase = handle_create()
     catch,error
     IF error NE 0 THEN BEGIN
        catch,/cancel
        sbase = handle_create()
     END
     handle_value,sbase,source,/no_copy,/set
     handle_value,sbase,destination,/no_copy
     return
  END
     
  IF NOT since_version('3.1') THEN destination = source
  
  IF NOT xalive(sbase) THEN sbase = widget_base()

  Widget_CONTROL,sbase,Set_UVALUE=source,/NO_COPY
  Widget_CONTROL,sbase,Get_UVALUE=destination,/NO_COPY
END
