- AFAIK, I've never had a situation like this, so it's possible that I'd refactor the code to avoid having to do this. (E.g. any function would depend only on variable n1, and n2 and n3 would be irrelevant.)
- If I did do this, I might use a function to update the values each time before using the variables.
- Possibly also, you could use a class. With properties 2 and 3 based on property 1.
Code: Select all
q:: ;test - update values
n1 := 5
FuncUpdateValues(n1, n2, n3)
MsgBox, % n1 " " n2 " " n3
n1 := 10
FuncUpdateValues(n1, n2, n3)
MsgBox, % n1 " " n2 " " n3
o := [5]
FuncUpdateArray(o)
MsgBox, % o.1 " " o.2 " " o.3
o := [10]
FuncUpdateArray(o)
MsgBox, % o.1 " " o.2 " " o.3
o := []
FuncUpdateArrayAlt(o, 5)
MsgBox, % o.1 " " o.2 " " o.3
FuncUpdateArrayAlt(o, 10)
MsgBox, % o.1 " " o.2 " " o.3
o := new ClassUpdateValues(5)
MsgBox, % o.1 " " o.2 " " o.3
o.1 := 10
MsgBox, % o.1 " " o.2 " " o.3
return
FuncUpdateValues(n1, ByRef n2, ByRef n3)
{
n2 := n1 + 1
n3 := n1 + 2
}
FuncUpdateArray(o)
{
o.2 := o.1 + 1
o.3 := o.1 + 2
}
FuncUpdateArrayAlt(o, n)
{
o.1 := n
o.2 := o.1 + 1
o.3 := o.1 + 2
}
class ClassUpdateValues
{
__New(value)
{
this.1 := value
}
2
{
get
{
return this.1 + 1
}
}
3
{
get
{
return this.1 + 2
}
}
}