Unable call "class variable" from "variable"

Get help with using AutoHotkey and its commands and hotkeys
holahapi
Posts: 61
Joined: 09 Nov 2016, 21:52

Unable call "class variable" from "variable"

19 Oct 2019, 02:48

It works in normal variables, but not in class variable.
Is there a way to make it work?

I think it is the problem of the ".", also tried use "`.", not working either.

Code: Select all

Class VarContainer
	{
	static vv_TestVar
	}



VarContainer.vv_TestVar := "Default"
msgbox % VarContainer.vv_TestVar

; RESULT:
; Default
; -------------------------------------------------------------

temp3 := "Default"
temp1 = temp3
%temp1% := "NEW"
msgbox % temp3

; RESULT:
; NEW
; -------------------------------------------------------------


VarContainer.vv_TestVar := "Default"
temp1 = VarContainer.vv_TestVar
%temp1% := "NEW"
msgbox % VarContainer.vv_TestVar

; RESULT:
; Error:  The following variable name contains an illegal character:
; "VarContainer.vv_TestVar"
Helgef
Posts: 4345
Joined: 17 Jul 2016, 01:02
Contact:

Re: Unable call "class variable" from "variable"

19 Oct 2019, 02:59

use obj[ expr ] := val. Eg,

Code: Select all

obj := {}
temp := "a"
obj[ temp ] := 123
msgbox % obj["a"] ; or obj.a
Cheers.
holahapi
Posts: 61
Joined: 09 Nov 2016, 21:52

Re: Unable call "class variable" from "variable"

19 Oct 2019, 09:26

Helgef wrote:
19 Oct 2019, 02:59
use obj[ expr ] := val. Eg,
Thank you, I dont know object before.
It also works in class variable too.
Thanks

Code: Select all

Class VarContainer
	{
	static vv_TestVar
	}


VarContainer.vv_TestVar := "Default"
temp1 = vv_TestVar
VarContainer[temp1] := "NEW"
msgbox % VarContainer[temp1]

; RESULT:
; Error:  The following variable name contains an illegal character:
; "VarContainer.vv_TestVar"

Return to “Ask For Help”

Who is online

Users browsing this forum: Google [Bot], guest3456, Joe Glines, MauroG, Odlanir and 143 guests