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

Home » Public Forums » archive » Re: associated variables in structures
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
Re: associated variables in structures [message #11192] Mon, 09 March 1998 00:00
davidf is currently offline  davidf
Messages: 2866
Registered: September 1996
Senior Member
Martin Schultz (mgs@io.harvard.edu) writes:

> I haven't gained any experience with associated variables yet, but my
> approach to this problem would be to figure out the filepos pointer to
> each of the images in a first step and then use this array of "pointers"
> (in fact they are long words) to quickly access the selected image that
> you want to read it in. Now, if David tells me that this is exactly what
> ASSOC is meant for, then I will change my program today!

Oh, oh. I have bad news, Martin. ASSOC is *exactly* a
way to position file pointers in a binary file without you
having to go to all that trouble to keep track of them.
Not only that, but the Associated Variable method is one
of the most efficient in terms of reading and writing
data into and out of files. Many people find it so
useful that they use it even when they *should* be using
something else. :-)

By the way, you can map many *different* associated
variables onto the same file. This great flexibility
is often useful if you have a particular complicated
file structure.

Cheers,

David

-----------------------------------------------------------
David Fanning, Ph.D.
Fanning Software Consulting
E-Mail: davidf@dfanning.com
Phone: 970-221-0438
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Re: associated variables in structures [message #11199 is a reply to message #11192] Mon, 09 March 1998 00:00 Go to previous message
Martin Schultz is currently offline  Martin Schultz
Messages: 515
Registered: August 1997
Senior Member
David Fanning wrote:
>
> Jacobus Koster (nosuch@ix.netcom.com) writes:
>
>> Wizards,
>
>
> No, indeed. An associated variable is not really, ...well, a
> variable. It is more of a mapping than a variable. It maps
> some kind of an organization onto a file in a way that makes
> it *appear* to be a variable.
>
> [...]

haven't gained any experience with associated variables yet, but my
approach to this problem would be to figure out the filepos pointer to
each of the images in a first step and then use this array of "pointers"
(in fact they are long words) to quickly access the selected image that
you want to read it in. Now, if David tells me that this is exactly what
ASSOC is meant for, then I will change my program today!

Martin.


------------------------------------------------------------ -------
Dr. Martin Schultz
Department for Earth&Planetary Sciences, Harvard University
186 Pierce Hall, 29 Oxford St., Cambridge, MA-02138, USA

phone: (617)-496-8318
fax : (617)-495-4551

e-mail: mgs@io.harvard.edu
IDL-homepage: http://www-as.harvard.edu/people/staff/mgs/idl/
------------------------------------------------------------ -------
Re: associated variables in structures [message #11205 is a reply to message #11192] Sat, 07 March 1998 00:00 Go to previous message
davidf is currently offline  davidf
Messages: 2866
Registered: September 1996
Senior Member
Jacobus Koster (nosuch@ix.netcom.com) writes:

> Wizards,

Reminds me of the Lord of the Rings trilogy I took a year
to read to my oldest son... :-)

> I've run into a problem with structures and associated variables, and I
> CANNOT be the first person to see this.
> {snip]
> But, apparently IDL 5.0 will not let me
> define an (anonymous) structure which has an associated variable in one
> of the fields.

No, indeed. An associated variable is not really, ...well, a
variable. It is more of a mapping than a variable. It maps
some kind of an organization onto a file in a way that makes
it *appear* to be a variable.

It would be hard to stick something like this into a field
of a structure, because a structure, after all, has to know
something about what is inside it. Or, in other words, it has
to know how BIG something is. And an associated variable isn't
big at all (although the file it maps may be big). I'm sure
there must be some incantation somewhere to tell you what an
associated variable is (internally, I mean), but I doubt you
and I would be privy to it.

In any case, you don't need it. You can conjure your way
around it.

What you want to carry around in your info structure is the
logical unit number of the file that is mapped to the associated
variable. Then, in your event handler you s-s-s-s-imply
recreate your mapping. Like this if you know what it is
going to be (as you apparently do):

thisVariable = ASSOC(info.lun, IntArr(128, 128))

Now you can read away to your hearts content!

(No need to specify how many images are in the file, by the way.
Associated variables don't need to know, nor do they care, how
big the actual file is. And please don't hard code your logical
unit numbers. The dark side lies in wait, look for ways to
spoil your programs. This is one of their favorites methods.)

OpenR, lun, filename, /Get_Lun

May dwarfs and elves appear in your dreams. :-)

Strider
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: flanagan@spacenet
Next Topic: Re: Quasi-freehand curve fitting...

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

Current Time: Wed Oct 08 19:43:38 PDT 2025

Total time taken to generate the page: 0.00613 seconds