Ah, good point. I hastily assumed because of the use of "me" that Michael
meant the reference was from within the object in question. But in certain
situations that syntax could also resolve to a property in an ancestor or
descendant.
-Jeff
At 1012 -0700 10/05/2005, Irv Kalb wrote:
>I believe that Jeff's suggestiong of using getAProp and setAProp will work.
>However, by doing this you are really breaking encapsulation. That is, you are
>allowing code "outside" of an object to reference property variables "inside"
>the object directly.
>
>A different approach is to use a case statement. That way, code which is
>outside the object can refer to properties using a name or a symbol, but only
>the code internally can actually set the value. For example:
>
>property pProp1
>propertp pProp2
>etc.
>
>on mSetSomething me, theProp, theValue
> case theProp of
> "prop1": -- or #prop1 if you prefer symbols
> pProp1 = theValue
>
> "prop2: -- or #prop2 if you prefer symbols
> pProp2 = the Value
>
> <etc.>
>
> otherwise:
> alert("Attempt to set something this object doesn't know about:" &&
> theProp)
> end case
>end
>
>This way, all reference to the parent's scripts real property names are kept
>internal to this script - and you can be free to change these names any time
>you like without affecting any external (calling) code.
>
>Irv
>
>At 3:06 PM +0200 10/3/05, Michael von Aichberger 2 wrote:
>>Hi List,
>>
>>in an object, I can easily set a property like this
>>
>>me.pSomething = 1
>>
>>But what, if I have the name of the property in a variable? Like
>>
>>myProp = symbol(pSomething)
>>
>>Writing
>>
>>me[myProp] = 1
>>
>>doesn't work,
>>
>>set myProp of me to 1
>>
>>doesn't work either.
>>
>>Any solution?
>>
>>...
>
>...
[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/lingo-l.cgi To post messages to the list, email
[email protected] (Problems, email [EMAIL PROTECTED]). Lingo-L is for
learning and helping with programming Lingo. Thanks!]