Just a (simple?) question.. how to pass a property of a class (or the object based on the class) WITHIN a function call ?
Something like
Code: Select all
#Requires AutoHotkey v2.0
testinstance := TESTME()
testinstance.MyFunction()
Class TESTME
{
myvar := "teststring"
MyFunction()
{
this.GetsCalled(&this.myvar)
}
GetsCalled(&myvarref)
{
myvarref := "newstring"
}
}
"Error: "&" requires a variable.
(..)
▶ 014: this.GetsCalled(&this.myvar)
(..)
The program will exit."
.. and, as far as I remember, the documentation states that references are not allowed for object properties, so not really a surprise..
But often than not, I need references to set some object properties within a function to change them.
I could pass them "as values" to "GetsCalled(..)" , change them and set them explicitely with something like " this.mystr := mystringnonref " (aka function header is changed to GetsCalled(mystringnonref) ) , but if "mystringnonref " would be an object (like a Buffer for a DLL Call), this would result in a reference to the local "mystringnonref" and vanish after completing "GetsCalled(..)" , right?
Which DOES work is passing the NAME of the property which I can de-reference then via "%" enclosing.. but this seems like a hack?
Code: Select all
#Requires AutoHotkey v2.0
testinstance := TESTME()
testinstance.MyFunction()
Class TESTME
{
myvar := "teststring"
MyFunction()
{
this.GetsCalled("myvar")
}
GetsCalled(myvarrefname)
{
this.%myvarrefname% := "newstring"
}
}