|
Re: object reference in a structure [message #12857 is a reply to message #12843] |
Thu, 17 September 1998 00:00  |
Vap User
Messages: 31 Registered: April 1998
|
Member |
|
|
"Charlie Solomon" <crsolomon@west.raytheon.com> writes:
>
> Hi everyone...is it possible to put an object reference in a structure
> variable? For example, I create a new object, then create a pointer to an
> info structure for my widget and try to include the object reference in the
> structure:
>
> junk = 'charlie was here'
> ptr_new, info( { junk:junk, oWindow:0 } )
>
Imminently doable. The thing you must store in the structure is a null object
reference. You get one in a way analogous to how you get a null
pointer reference, i.e. with Obj_New(). Try...
Widget_Control, widget_id_where_you_want_to_store_this_info, $
set_UValue=Ptr_New( { junk:junk, oWindow: Obj_new() } )
Then everything else will work fine. I do this sort of thing all the time.
>
> But when I try to access it bad things happen (I can get the actual error
> message if needed). Here's how I try to access it:
>
> (*info).oWindow = obj_new('IDLgrWindow') ;no worky
> (*info).oWindow -> method, keywords ;no worky
>
> Should I even be trying this? I want to be able to store the object
> reference in info after it is created in another procedure and passed back
> so that my widget program can modify properties and destroy it based on
> xmanager events. Thanks!
>
>
--
I don't speak for JPL, it doesn't speak for me.
Well, not all the time, at least.
William Daffer <vapuser@haifung.jpl.nasa.gov>
|
|
|
Re: object reference in a structure [message #12890 is a reply to message #12857] |
Tue, 15 September 1998 00:00  |
Phillip & Suzanne
Messages: 31 Registered: June 1998
|
Member |
|
|
Charlie Solomon wrote:
;> Hi everyone...is it possible to put an object reference in a structure
;> variable? For example, I create a new object, then create a pointer to an
;> info structure for my widget and try to include the object reference in the
;> structure:
;> junk = 'charlie was here'
;> ptr_new, info( { junk:junk, oWindow:0 } )
Try this:
junk='charlie was here'
ptr_new, info({junk:junk, oWindow:Obj_New()} )
;> But when I try to access it bad things happen (I can get the actual error
;> message if needed). Here's how I try to access it:
;> (*info).oWindow = obj_new('IDLgrWindow') ;no worky
;> (*info).oWindow -> method, keywords ;no worky
;> Should I even be trying this? I want to be able to store the object
;> reference in info after it is created in another procedure and passed back
;> so that my widget program can modify properties and destroy it based on
;> xmanager events. Thanks!
The problem really turns out to be one of data types. An IDL object reference
is not a short integer. I believe it is a long integer, but Obj_New() returns
a null object reference that is definitely the correct type. Once this is set
up, I believe you'll be in great shape.
Phillip
|
|
|