Re: Way around zeroing of structures on creation? [message #62183] |
Thu, 28 August 2008 13:20 |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Christopher Thom writes:
> I have a simple routine that defines a structure I use a lot, so that the
> definition is automatic when I call it. e.g.
>
> pro mystrct__define
> tmp = {mystrct, $
> foo:0.0d, $
> bar:2.365434d
> }
> end
>
> The help pages about automatic structure definition are very explicit that
> all fields of a structure that is created by copying in this way will be
> zeroed (or strings converted to null strings).
>
> So...my question is, does anyone know a neat way around this? I want to
> fill my structure with useful constants that will not change, but i'd like
> to avoid having to do it by hand every time I create an instance of the
> structure.
Well, I guess you have thought of the obvious:
function mystrct
tmp = {mystrct, $
foo:0.0d, $
bar:2.365434d
}
return, tmp
end
IDL> thisStruct = Mystruct()
If you want it to be created the way YOU want it created,
why let IDL fool around with it?
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
|
|
|