Way around zeroing of structures on creation?

This is a discussion on Way around zeroing of structures on creation? within the Idl-pvwave forums in Programming Languages category; 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 ...

Go Back   Application Development Forum > Programming Languages > Idl-pvwave

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 08-28-2008, 04:01 PM
Christopher Thom
Guest
 
Default Way around zeroing of structures on creation?

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
Reply With Quote
  #2  
Old 08-28-2008, 04:20 PM
David Fanning
Guest
 
Default Re: Way around zeroing of structures on creation?

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.")
Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 02:33 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.