Re: Returning values within _EXTRA. [message #12486] |
Thu, 13 August 1998 00:00  |
Vap User
Messages: 31 Registered: April 1998
|
Member |
|
|
Imanol Echave <ccaeccai@sc.ehu.es> writes:
I'm going to answer this one again to spare myself a little egg on the
face occasioned by my previous answer. I just read the help for
Obj_destroy and find that you can specify both arguments and keywords.
So you should pass keywords to the getproperty method using
_ref_extra.
Consider the following
FUNCTION junk::Init, prop1, prop2
IF n_params() NE 2 THEN return,0
self.prop1 = prop1
self.prop2 = prop2
return,1
END
PRO junk::cleanup, _ref_extra = extra
self-> get,_extra = extra
END
PRO junk::get, prop1 = prop1, prop2=prop2
IF arg_present( prop1 ) THEN prop1 = self.prop1
IF arg_present( prop2 ) THEN prop2 = self.prop2
END
PRO junk::set, prop1 = prop1, prop2=prop2
IF n_elements( prop1 ) NE 0 THEN self.prop1 = prop1
IF n_elements( prop2 ) NE 0 THEN self.prop2 = prop2
END
PRO junk__define
junk = {JUNK,$
prop1:0l,$
prop2:0l }
END
IDL> .run /tmp/junk__define.pro
% Compiled module: JUNK::INIT.
% Compiled module: JUNK::CLEANUP.
% Compiled module: JUNK::GET.
% Compiled module: JUNK::SET.
% Compiled module: JUNK__DEFINE.
IDL> j=obj_new('junk',1,2)
IDL> j->get,prop1=p1,prop2=p2 & print,p1,p2
1 2
IDL> j->set,prop1=3,prop2=10
IDL> j->get,prop1=p1,prop2=p2 & print,p1,p2
3 10
IDL> obj_destroy,j,prop1=pp1,prop2=pp2
IDL> print,pp1,pp2
3 10
IDL>
>
> Hi people:
>
> When you use a keyword parameter on a program, it's possible to change the
> value of the keyword (if it's a named value), OK. But, I want to do the same
> using the _EXTRA keyword, and it doesn't work (because a tag of a structure is
> passed by value, I think). Anybody knows how to do it?
>
> An example: I'm creating a class, and on the CLEANUP method I want to return
> the object properties values on keywords, so I call the GETPROPERTY method
> within the CLEANUP method. I tried this:
>
> PRO ...::Cleanup,_EXTRA=extra
>
> self->GetProperty,_EXTRA=extra
> ...
> END
>
> But it doesn't work. Any advice?
--
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>
|
|
|