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

Home » Public Forums » archive » Defining Integer Field in a Structure
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Defining Integer Field in a Structure [message #27736] Thu, 01 November 2001 13:07 Go to next message
sailfalmouth is currently offline  sailfalmouth
Messages: 6
Registered: September 2001
Junior Member
Is there a way to define a field within a structure whose type is
integer? In my case, I want the field to be any integer from 0 to 4.
I know you can assign an actual integer to the field, but I don't want
to do this because I want the field value to change within certain
procedures and to return that value to the procedures calling it. I
would appreciate any help you might be able to offer.

Thanks,

Brian
Re: Defining Integer Field in a Structure [message #27819 is a reply to message #27736] Tue, 06 November 2001 19:07 Go to previous message
Mark Hadfield is currently offline  Mark Hadfield
Messages: 783
Registered: May 1995
Senior Member
From: "Harvey Rarback" <rarback@slac.stanford.edu>
>>>> PRO newstruct__define.pro
>>>> struct = {NEWSTRUCT, a:0, b:0.0, c:fltarr(10)}
>>>> END
>> Certainly an instance of this structure gets created
>> in this routine, but its existence is fleeting. ...
> Yes. It's what I thought was happening. What bothered me
> was the overhead in creating the temporary structure.

First, the overhead is very small unless there are large amounts of data in
the structure. (And it's generally bad practice to include large amounts of
data in a named structure, because this is inflexible, so one generally uses
pointers instead.)

Second, the NEWSTRUCT__DEFINE procedure is normally run only once, when IDL
is asked to create a named structure and doesn't have a definition for it.
Of course, you can run it yourself as often as you like but this doesn't
achieve a great deal...

---
Mark Hadfield
m.hadfield@niwa.cri.nz http://katipo.niwa.cri.nz/~hadfield
National Institute for Water and Atmospheric Research



--
Posted from clam.niwa.cri.nz [202.36.29.1]
via Mailgate.ORG Server - http://www.Mailgate.ORG
Re: Defining Integer Field in a Structure [message #27820 is a reply to message #27736] Tue, 06 November 2001 18:09 Go to previous message
Harvey Rarback is currently offline  Harvey Rarback
Messages: 24
Registered: September 1998
Junior Member
"David Fanning" <david@dfanning.com> wrote in message
news:MPG.16523ca91d6c3e4a989757@news.frii.com...
> Harvey Rarback (rarback@slac.stanford.edu) writes:
>
>>> If you wish to create a stucture definition without
>>> actually creating an instance of a structure, you
>>> put the structure definition in a file, like this:
>>>
>>> PRO newstruct__define.pro
>>> struct = {NEWSTRUCT, a:0, b:0.0, c:fltarr(10)}
>>> END
>>
>> This is something that has always confused me. It seems like the
variable
>> "struct" is created (at least help will tell you that it exists). So,
does IDL
>> "actually create an instance of a structure" with this mechanism or not?
>
> Well, of course, I was speaking metaphorically. :-)
>
> Certainly an instance of this structure gets created
> in this routine, but its existence is fleeting. In
> fact, it exists only as long as it takes to establish
> the structure definition in IDL. Once that done, the
> struct variable goes out of scope and the memory that
> was allocated for its definition can be reused by
> the real structure you are trying to create. Think
> of it as smoke and mirrors.
>
> Does that clear up the confusion?

Yes. It's what I thought was happening. What bothered me
was the overhead in creating the temporary structure.

--Harvey
Re: Defining Integer Field in a Structure [message #27823 is a reply to message #27736] Tue, 06 November 2001 17:30 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Harvey Rarback (rarback@slac.stanford.edu) writes:

>> If you wish to create a stucture definition without
>> actually creating an instance of a structure, you
>> put the structure definition in a file, like this:
>>
>> PRO newstruct__define.pro
>> struct = {NEWSTRUCT, a:0, b:0.0, c:fltarr(10)}
>> END
>
> This is something that has always confused me. It seems like the variable
> "struct" is created (at least help will tell you that it exists). So, does
> IDL
> "actually create an instance of a structure" with this mechanism or not?

Well, of course, I was speaking metaphorically. :-)

Certainly an instance of this structure gets created
in this routine, but its existence is fleeting. In
fact, it exists only as long as it takes to establish
the structure definition in IDL. Once that done, the
struct variable goes out of scope and the memory that
was allocated for its definition can be reused by
the real structure you are trying to create. Think
of it as smoke and mirrors.

Does that clear up the confusion?

Cheers,

David

P.S. Harvey, it is good to hear from you again. I was
afraid you had found something more productive than
IDL to do. :-)
--
David W. Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: RSI, Mac and Tru64
Next Topic: Returning A Variable Length struct to IDL from C

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

Current Time: Wed Oct 08 13:51:46 PDT 2025

Total time taken to generate the page: 0.00704 seconds