refer to self (this)

Discuss Lemur and share techniques.
Post Reply
nikisoko
Newbie
Posts: 3
Joined: 18 Feb 2012 06:35

refer to self (this)

Post by nikisoko »

Is there a way to refer to the object that a script is acting on? What I mean is if I'm doing something like the following:

round(x*getattribute(MultiSlider, 'nbr'))

I would like to change MultiSlider to something like 'this' or 'self' so that I don't have to go in and edit the script every time I make change the name of the object or make a copy of the object.

Thanks,
-Nick
Macciza
Regular
Posts: 1315
Joined: 07 Dec 2011 04:57
Location: Sydney, Australia.

Re: refer to self (this)

Post by Macciza »

Hi

I think you want 'getobject()' passing nothing as the argument returns the enclosing object , ,
Use it by declaring something like

decl this = getobject();
out = round(x*getattribute(this, 'nbr'));

Can also be used to get/store references to any object
An implicit 'this' function has also been requested on the wishlist from memory . . .
Cheers
MM
iMac 2.8G i7 12G 10.6.8/10.7.2, Legacy Dexter/Lemur, Liine Lemur/iPad2, KMI SoftStep, 12Step & QuNeo , B-Controls, Mackie C4 etc
MaxMSP, Live Suite, Native Instrument stuff, etc Modified Virtual Guitar System etc All Projects/Modules © CC-BY-NC-SA[*][/b]
nikisoko
Newbie
Posts: 3
Joined: 18 Feb 2012 06:35

Re: refer to self (this)

Post by nikisoko »

that works! thanks!
analog604
Regular
Posts: 262
Joined: 29 Dec 2011 15:40
Location: north east, usa

Re: refer to self (this)

Post by analog604 »

Thanks for asking about this Nick i've been asking myself how to do this, but have just moved on and continued working.
Macciza thank you sir for the answer! I remember someone asking for a ob ref 'this' as well.

Macciza wrote:Hi

I think you want 'getobject()' passing nothing as the argument returns the enclosing object , ,
Use it by declaring something like

decl this = getobject();
out = round(x*getattribute(this, 'nbr'));

Can also be used to get/store references to any object
An implicit 'this' function has also been requested on the wishlist from memory . . .
Cheers
MM
Dashboard gear control templates: User 112 Idx :: LModIt Lite :: SVG image converter for Lemur Canvas
Post Reply