object wizards [message #21978] |
Fri, 13 October 2000 00:00 |
Bernard Puc
Messages: 65 Registered: January 1998
|
Member |
|
|
Hello,
Apparently, an array created with objarr() can only store one type of
object. And thats consistent with arrays of structures. But, I want to
store several different objects together somehow in a single variable.
A structure doesn't work since I have a variable number of objects to
store. Therefore, is the only way to do this with an array of pointers,
where each pointer references an object reference?
Any ideas much appreciated.
--
Bernard Puc AETC, INC.
bpuc@va.aetc.com 1225 Jefferson Davis Highway #800
(703) 413-0500 Arlington, VA 22202
|
|
|
Re: object wizards [message #22068 is a reply to message #21978] |
Fri, 13 October 2000 00:00  |
Bernard Puc
Messages: 65 Registered: January 1998
|
Member |
|
|
David Fanning wrote:
>
> Bernard Puc (bpuc@va.aetc.com) writes:
>
>> Apparently, an array created with objarr() can only store one type of
>> object. And thats consistent with arrays of structures. But, I want to
>> store several different objects together somehow in a single variable.
>> A structure doesn't work since I have a variable number of objects to
>> store. Therefore, is the only way to do this with an array of pointers,
>> where each pointer references an object reference?
>
> Why would you think this!? This simple test works well:
>
> IDL> a=objarr(2)
> IDL> a[0] = Obj_New('idlgrSurface')
> IDL> a[1] = Obj_New('idlgrPlot')
>
> An object reference is an object reference. I can't see
> how ObjArr or anyone else can object. :-)
Yep, you're absolutely right. I was misinterpreting the IDL error
message. The problem I'm having is that I am defining an object with
one of the data elements initialized as an objarr(1). Then, later on I
am trying to append another object onto that array. I think what I need
is a pointer to the object array.
--
Bernard Puc AETC, INC.
bpuc@va.aetc.com 1225 Jefferson Davis Highway #800
(703) 413-0500 Arlington, VA 22202
|
|
|
Re: object wizards [message #22072 is a reply to message #21978] |
Fri, 13 October 2000 00:00  |
Martin Schultz
Messages: 515 Registered: August 1997
|
Senior Member |
|
|
Bernard Puc wrote:
>
> Hello,
>
> Apparently, an array created with objarr() can only store one type of
> object. And thats consistent with arrays of structures. But, I want to
> store several different objects together somehow in a single variable.
> A structure doesn't work since I have a variable number of objects to
> store. Therefore, is the only way to do this with an array of pointers,
> where each pointer references an object reference?
>
> Any ideas much appreciated.
> --
> Bernard Puc AETC, INC.
> bpuc@va.aetc.com 1225 Jefferson Davis Highway #800
> (703) 413-0500 Arlington, VA 22202
My advice would be to use a container. These are specifically designed
for this purpose. If you decide to do so, you may want to take a look
at my mgs_container object which you can find on my web pages:
http://www.mpimet.mpg.de/~schultz.martin/idl/
This extends the IDL_Container functionality by allowing object access
by name.
Cheers,
Martin
--
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ [[[[[[[
[[ Dr. Martin Schultz Max-Planck-Institut fuer Meteorologie [[
[[ Bundesstr. 55, 20146 Hamburg [[
[[ phone: +49 40 41173-308 [[
[[ fax: +49 40 41173-298 [[
[[ martin.schultz@dkrz.de [[
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ [[[[[[[
|
|
|