| Register | FAQ | Calendar | Search | Today's Posts | Mark Forums Read |
|
#1
| |||
| |||
| Hi all, 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. cheers chris |
|
#2
| |||
| |||
| 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.") |
![]() |
| Thread Tools | |
| Display Modes | |
In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.