Question about Class variables

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
Klark92
Posts: 161
Joined: 18 Jan 2015, 19:33

Question about Class variables

12 Aug 2018, 05:52

Code: Select all

WebRequest := ComObjCreate("WinHttp.WinHttpRequest.5.1")
WebRequest.Open("GET", "http://www.google.com/", True)
WebRequest.SetRequestHeader("Accept", "text/html, application/xhtml+xml, */*")
WebRequest.SetRequestHeader("User-Agent", "Android")
WebRequest.Option(6) := False
WebRequest.Send()
WebRequest.WaitForResponse()
msgbox % WebRequest.ResponseText
What is the meaning of Option(6) ? Is that a variable and how can I declare it like that in a class ? thanks

Code: Select all

Option(index)
{
	set
	{
		if (index = 6)
			this.Option(index) := value
	}
}
Smart Kombo 1.0 | One of the best Knight Online's key combo program...
Helgef
Posts: 4709
Joined: 17 Jul 2016, 01:02
Contact:

Re: Question about Class variables

12 Aug 2018, 06:36

See object properties and syntax remarks. Example,

Code: Select all

class c {
	Option[k]{
		set {
			return this.opt[k] := value
		}
		get {
			return this.opt[k]
		}
	}
}
c.option(6) := false
msgbox % c.option(6)
Also note the difference in which meta-functions will be invoked (when using an object derived from the class) for the two syntaxes: () vs[], the latter is probably better for custom classes. That is, do c.option[6] := false, c.option[6] instead.

Cheers.
User avatar
Klark92
Posts: 161
Joined: 18 Jan 2015, 19:33

Re: Question about Class variables

12 Aug 2018, 08:37

thank you. that solved my problem. :beard:
Smart Kombo 1.0 | One of the best Knight Online's key combo program...

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Araphen, Bobak, mapcarter and 309 guests