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

Home » Public Forums » archive » Initializing object array
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
Initializing object array [message #38431] Mon, 08 March 2004 19:17 Go to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Folks,

I've been programming fast and furious for nearly 12 hours straight.
Can't think straight. Not enough postings here today to distract
me. :-(

Anyway, I can use some succor.

I have an object. One of the fields of this objects
is a object array. The field is called "contours":

PRO myclass__define
class = { MYCLASS, contours:Obj_New()}
END

Now, when I create the object, I want to pass an object
array of ROI objects that I created somewhere else.

FUNCTION myclass::INIT, Contours=contours
self.contours = contours
RETURN, 1
END

This doesn't work. Says contours must be a scalar
in this context. Well!!! Shucks.

Surely I have done this before. But I can't for the
life of me remember how. How do I initialize a field
as an object array?

Yours in programming-induced stupidity,

David

P.S. Let's just say if I can just get over this one little
hurtle that this program from hell may actually be finished!

--
David Fanning, Ph.D.
Fanning Software Consulting
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Re: Initializing object array [message #38491 is a reply to message #38431] Wed, 10 March 2004 20:12 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
JD Smith writes:

> An object container is just a fancy wrapper around using a pointer to hold
> a bunch of objects. So you can go either way. I personally prefer the
> transparency of using your own pointer.

I don't know. It's not just fancy, I think it's elegant.
For holding objects, I really do prefer a container. :-)

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Re: Initializing object array [message #38495 is a reply to message #38431] Wed, 10 March 2004 15:24 Go to previous messageGo to next message
JD Smith is currently offline  JD Smith
Messages: 850
Registered: December 1999
Senior Member
On Tue, 09 Mar 2004 10:38:37 -0700, David Fanning wrote:

> Ben Tupper writes:
>
>> [quoted text muted]
>
> Yes, thank you everyone. It is clear in the light of day that
> what I wanted was a container not an object array. But you know
> how it is, you are frantic to finish, you have been programming
> for hours and hours, and somehow you just get an idea stuck in
> your mind that for some reason you *don't* want a container
> here. I've got to get my mind off of how much money I'm
> not making. :-(

An object container is just a fancy wrapper around using a pointer to hold
a bunch of objects. So you can go either way. I personally prefer the
transparency of using your own pointer.

JD
Re: Initializing object array [message #38515 is a reply to message #38431] Tue, 09 March 2004 12:04 Go to previous messageGo to next message
Mark Hadfield is currently offline  Mark Hadfield
Messages: 783
Registered: May 1995
Senior Member
David Fanning wrote:
> Yes, thank you everyone. It is clear in the light of day that
> what I wanted was a container not an object array. But you know
> how it is, you are frantic to finish, you have been programming
> for hours and hours, and somehow you just get an idea stuck in
> your mind that for some reason you *don't* want a container
> here.

Perhaps you didn't want the contained objects to be destroyed with the
container, as IDL_Container is wont to do.

> I've got to get my mind off of how much money I'm
> not making. :-(

I know how you feel. I didn't make $10 million dollars last year.


--
Mark Hadfield "Ka puwaha te tai nei, Hoea tatou"
m.hadfield@niwa.co.nz
National Institute for Water and Atmospheric Research (NIWA)
Re: Initializing object array [message #38594 is a reply to message #38431] Fri, 12 March 2004 09:09 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Stein Vidar Hagfors Haugan writes:

> Anyhow, here is what I think you were *really* trying to do in the
> first place:

Well, heck, if I knew what I was *really* trying to do,
do you think I would be writing to the IDL newsgroup! :-)

I appreciate all the suggestions. Pressure (without enough
tennis) just makes you crazy.

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Re: Initializing object array [message #38595 is a reply to message #38491] Fri, 12 March 2004 08:48 Go to previous message
Stein Vidar Hagfors H[2] is currently offline  Stein Vidar Hagfors H[2]
Messages: 28
Registered: October 2002
Junior Member
David Fanning <david@dfanning.com> writes:

> JD Smith writes:
>
>> An object container is just a fancy wrapper around using a pointer to hold
>> a bunch of objects. So you can go either way. I personally prefer the
>> transparency of using your own pointer.
>
> I don't know. It's not just fancy, I think it's elegant.
> For holding objects, I really do prefer a container. :-)

Isn't it more awkward to e.g. loop in a one-line statement over the
contents of a container?

Anyhow, here is what I think you were *really* trying to do in the
first place:

FUNCTION MyProg::INIT, a
self.c = ptr_new(a)
RETURN, 1
END

PRO MyProg__Define
class = {MYPROG, c:Obj_New()}
END

And *self.c would be the array "a" of object pointers.

------------------------------------------------------------ --------------
Stein Vidar Hagfors Haugan
ESA SOHO SOC/European Space Agency Science Operations Coordinator for SOHO

NASA Goddard Space Flight Center, Tel.: 1-301-286-9028
Mail Code 682.3, Bld. 26, Room G-1, Cell: 1-240-354-6066
Greenbelt, Maryland 20771, USA. Fax: 1-301-286-0264
------------------------------------------------------------ --------------
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: append a matrix after a .dat file which stores all similar matrix
Next Topic: Re: append a matrix after a .dat file which stores all similar matrix

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

Current Time: Wed Oct 08 15:23:00 PDT 2025

Total time taken to generate the page: 0.00531 seconds