how do i get the value from class Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
ananthuthilakan
Posts: 188
Joined: 08 Jul 2019, 05:37
Contact:

how do i get the value from class

Post by ananthuthilakan » 02 Feb 2023, 06:51

Code: Select all

test:= new testClass()

f1::
msgbox, % test.Recentlychanged().1
return



Class testClass {

setid()
{
ControlGuid:=34 , value:= 56
this.Recentlychanged(ControlGuid,value)
}


Recentlychanged(ControlGuid:="",value:="")
	{
		static t
		if (ControlGuid)
		{
		t:=[]
		t[1]:=ControlGuid , t[2]:=value
		}
		return t
	}

}
how do i get the value from class like the above
any help would be mush appreciated.
i have been scratching my head for 2 days :morebeard:

teadrinker
Posts: 4326
Joined: 29 Mar 2015, 09:41
Contact:

Re: how do i get the value from class

Post by teadrinker » 02 Feb 2023, 07:24

Can you describe how you think this script should work?

ananthuthilakan
Posts: 188
Joined: 08 Jul 2019, 05:37
Contact:

Re: how do i get the value from class

Post by ananthuthilakan » 02 Feb 2023, 07:46

what i am trying to achieve

there is class named testClass
inside this class there is a function named setid()

the function setid() after some intial calculation set values for ControlGuid and its value
and then these variables are passed onto another function. lets say Recentlychange()

i need to get the value from this Recentlychanged() funtion somehow to main script ?


here what i tried was to create 2 optional parameter, such that
i could call the function from main script to get last changed value.
meanwhile other functions in the class can change the values of Recentlychanged() function.

and again i should be able to retrieve this most recent value from main script when i want

i dont really understand class , may be i am doing something dumb
thank you for your interest though

User avatar
boiler
Posts: 16925
Joined: 21 Dec 2014, 02:44

Re: how do i get the value from class  Topic is solved

Post by boiler » 02 Feb 2023, 08:23

You have never run setid() in what you’ve shown, so the values were never passed to Recentlychanged(). It displays the value if you do so first:

Code: Select all

test.setid()
msgbox, % test.Recentlychanged().1

Or just change the name of setid() to __New() so it initializes upon instantiation of the class. It seems like this how you were expecting it to work.


Post Reply

Return to “Ask for Help (v1)”