02 May 2013 08:10 AM |
|
I have defined classes with properties through getProperty() and setProperty. It works fine in that other classes can access these properties on the class it defined them as well as on its subclasses. However, within the defining class (and its subclasses), the properties seem invisible (Tag name XXX is undefined for structure YYY). It seems as if "self" is only seeing the structure of its DEFINE. Is this by design, or am I doing something wrong here?
|
|
|
|
Deleted User New Member
Posts:  
02 May 2013 08:34 AM |
|
Hmm, I am afraid I found the answer:
Under most circumstances, if you get or set an object property using the dot operator, IDL will call the object's GetProperty or SetProperty method. However, if inside of a method you get or set a property of the self object, IDL will access the property directly.
If this is tue it's kind of bizar, two different things that go by the same identifier. Apparently there's no distinction between the property and the underlying variable.
|
|
|
|
Deleted User New Member
Posts:  
02 May 2013 09:43 AM |
|
Here's a fun trick to get around this. Rather than specifying "print, self.x", try using the syntax "print, (self).x" when your intent is to call ::getproperty or ::setproperty. Alternatively, create a copy of self first, for example "s = self & print, s.x". There should only be a slight hit to execution since you're only copying the object reference or treating it as an expression.
I'd offered to write a IDL blog post on this entitled "Not feeling like my self", but the idea was shot down. :-(
|
|
|
|
Deleted User New Member
Posts:  
02 May 2013 03:35 PM |
|
Send it to me. I'll publish it under Coyote's byline. :-)
|
|
|
|
Deleted User New Member
Posts:  
03 May 2013 09:02 AM |
|
Jim Pendleton wrote:
try using the syntax "print, (self).x" when your intent is to call ::getproperty or ::setproperty. Alternatively, create a copy of self first, for example "s = self & print, s.x".
Jolly good trick! Only my IDL is not fooled by the first one (=(self).x )
|
|
|
|
Deleted User New Member
Posts:  
03 May 2013 10:15 AM |
|
I stand corrected. Putting my self into a parenthetical expression (something I am known to do in real life) frequently fails to lead me to the expected outcome. Life's lesson learned again.
|
|
|
|