ObjByRef

Creates an object containing ByRef variables, obj.var returns actual variable content and obj.var := value will assign new value to variable.


OutputVar := ObjByRef(Var1 , Var2, ...)
Function Example: ByRefObj := ObjByRef(Var1)

Parameters

OutputVar

The name of the variable in which to store the object.

Var1, Var2, ...

The name of the variable which reference will be stored in the object, key will be the name of the variable.

General Remarks

ByRefObj can also accept a new variable, simply use ByRefObj.newvar:=newvar. Other than calling ObjByRef() where key = VarName, when assigning new variable any name for the key can be used, e.g. ByRefObj.MyName:=Name

Examples

var2:=""
ByRefObj := ObjByRef(var:="Hello World!")
MsgBox ByRefObj.var ; returns content of var
ByRefObj.var := "Hello AHK!" ; assign new content to var
MsgBox var
ByRefObj.newvar:=var2 ; add new variable to ByRefObj but use newvar instead of var2 as key name
ByRefObj.newvar:=1 ; assign new content to var
MsgBox var2