comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Copying an object
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Copying an object [message #17000 is a reply to message #16997] Wed, 01 September 1999 00:00 Go to previous messageGo to previous message
Mark Hadfield is currently offline  Mark Hadfield
Messages: 783
Registered: May 1995
Senior Member
Following up my own post! Well, someone has to do it.

I forgot to note that MGH_OBJ_CLONE calls another of my routines,
RANDOM_NAME (which I may well rename to MGH_RANDOM_NAME some day). They can
be found at the following URLs

http://katipo.niwa.cri.nz/~hadfield/gust/software/idl/mgh_ob j_clone.pro
http://katipo.niwa.cri.nz/~hadfield/gust/software/idl/random _name.pro

and are also included below

---
Mark Hadfield
m.hadfield@niwa.cri.nz http://katipo.niwa.cri.nz/~hadfield/
National Institute for Water and Atmospheric Research
PO Box 14-901, Wellington, New Zealand

;+
; NAME:
; MGH_OBJ_CLONE
;
; PURPOSE:
; Given a reference to an object heap variable, this function generates
; a copy and returns its reference.
;
; CALLING SEQUENCE:
; Result = MGH_OBJ_CLONE(Object)
;
; INPUTS:
; Object: An object reference.
;
; RESTRICTIONS:
; Cloning child objects is not advisable because it leads to
inconsistencies
; between the parent's and child's information about the relationship.
;
; MODIFICATION HISTORY:
; Mark Hadfield, Feb 1998:
; Written as OBJ_CLONE.
; Mark Hadfield, Sep 1998:
; Renamed MGH_OBJ_CLONE.
;-
function MGH_OBJ_CLONE, Object, VERBOSE=verbose

if 1-obj_valid(Object) then return, obj_new()

; Copy the reference to a new variable so that the original will
; not be overwritten.

clone = object

file = filepath(random_name()+'.idl_object', /TMP)

if keyword_set(verbose) then message, /INFORM, 'Saving object to file
'+file

save, clone, FILE=file

restore, file

if keyword_set(verbose) then message, /INFORM, 'Deleting file '+file

file_delete, file

return, clone

end

;+
; NAME:
; RANDOM_NAME
;
; PURPOSE:
; This function returns a random 8-character string which is very unlikely
to be repeated.
;
; CALLING SEQUENCE:
; Result = RANDOM_NAME()
;
; MODIFICATION HISTORY:
; Mark Hadfield, April 1997:
; Written.
;-
function RANDOM_NAME

common random_name_common, seed

return, strtrim( string((randomu(seed,1))[0]*2L^31, FORM = '(Z)'), 2)

end
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: objarr
Next Topic: Re: simple question about bytes

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Sat Oct 11 22:10:00 PDT 2025

Total time taken to generate the page: 0.79891 seconds