Page 1 of 1

Question about Class variables

Posted: 12 Aug 2018, 05:52
by Klark92

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
	}
}

Re: Question about Class variables

Posted: 12 Aug 2018, 06:36
by Helgef
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.

Re: Question about Class variables

Posted: 12 Aug 2018, 08:37
by Klark92
thank you. that solved my problem. :beard: