About meta-functions change, Properties?

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
bourdin07
Posts: 36
Joined: 23 Jun 2019, 12:57

Re: About meta-functions change, Properties?

12 Feb 2020, 10:38

I dont know if its possible but I want to set a value to a property like this

Code: Select all

class MyClass
{
	MyProp
	{
		set
		{
			; Here I want some logic (very important)
			; then set the value to this MyProp
			
			return this.MyProp := value
		}
	}
}
The problem is that there is infinite loop, any idea how to set value
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: About meta-functions change, Properties?

04 Aug 2020, 05:58

it cant be done.
there needs to be some other place where u store ur data in/retrieve ur data from, like a differently-named instance variable on the object or a static variable inside the getter/setter(or a variable bound to the getter/setter, get creative)
the most straightforward solution is storing it inside a similarly named value property, eg

Code: Select all

class MyClass
{
	_MyProp := 'some default value'
	
	MyProp
	{
		set
		{
			; Here I want some logic (very important)
			; then set the value to this MyProp
			
			return this._MyProp := value
		}
	}
}

Return to “Ask for Help (v2)”

Who is online

Users browsing this forum: Bing [Bot], MSN [Bot], Rohwedder, RussF and 38 guests