[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Structure field concatenation

Ben Tupper (pemaquidriver@tidewater.net) writes:

> I know that this has been a subject of some discussion recently... but
> I'm still not on firm footing on the best method of changing the size of
> an anonymous structure's fields (i.e. I want to increase or decrease the
> size of a field).   The code below shows an example of how I do it now:
> creating a new structure with the appropriately sized fields.  Is there
> a better method?

No, no, no. A "better method!?" Yes, there is a better method. :-)

Here is a new rule for you.

  ANY time you have a structure member changing either
  size or data type, make that structure member a pointer.

     struct = { fish: Ptr_New(runOfTheMillFish), ... }

  Later, when something changes:

     *struct.fish = sexyNewFish

All you have to do is remember to clean this pointer up
in some kind of cleanup routine, or before you exit the
program. And don't worry about cleaning up memory and
all of that when you make the new assignment. IDL is 
going to take care of that for you. Isn't that nice? :-)

You must have taken my class a LONG time ago. It is
this kind of embarrassing nonsense that finally got
me off my duff and writing again. I'll send you a copy
of the new book (due out in September). :-)

> BTW:   I don't want to steer the discourse toward a scandalous sidebar
> discussion, but...  I'm wrestling with this because a shrimp starts out
> as a male and then ends up as a female a few years later.   I'm working
> with a database that has the shrimp broken down into records by sex...
> but I need to add new records for aggregate sex (that is the sum of
> males, transitionals, females,...)   I never thought IDL programming
> could be so titillating.

This kind of talk is TOTALLY inappropriate in this newsgroup.
Take it on over to alt.xxx.sex.fetish.fish.


David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155