Initializing object array [message #38431] |
Mon, 08 March 2004 19:17  |
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 #38594 is a reply to message #38431] |
Fri, 12 March 2004 09:09  |
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  |
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
------------------------------------------------------------ --------------
|
|
|