<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK: Проблема class proretries object array]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=14272&amp;type=atom" />
	<updated>2018-10-23T18:25:37Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=14272</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Проблема class proretries object array]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=129406#p129406" />
			<content type="html"><![CDATA[<p>Вот <a href="https://autohotkey.com/docs/Objects.htm#Custom_Classes_property">тут</a> читайте:<br /></p><div class="quotebox"><blockquote><p>Parameters can be passed by enclosing them in square brackets to the right of the property name, both when defining the property and when calling it.</p></blockquote></div><p>Информации о классах в справке достаточно, но, действительно, не всегда всё сразу понятно. Видимо, она рассчитана на тех, кто имел дело с классами в других языках.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2018-10-23T18:25:37Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=129406#p129406</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Проблема class proretries object array]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=129403#p129403" />
			<content type="html"><![CDATA[<p>Снова благодарю. <br />Я черным по белому читал, что квадратные скобки опциональны, можно не указывать. А тут вот как получается.<br />Если у вас есть информация с примерами построения классов на ahk, я бы с удовольствием ознакомился.</p>]]></content>
			<author>
				<name><![CDATA[upsi_daezium]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=34120</uri>
			</author>
			<updated>2018-10-23T17:34:30Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=129403#p129403</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Проблема class proretries object array]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=129402#p129402" />
			<content type="html"><![CDATA[<p>Переменные с префиксом &quot;_&quot; в данном случае имеют служебное значение и семантически не предназначены для того, чтобы к ним обращались извне. Вообще грамотнее было бы так:<br /></p><div class="codebox"><pre><code>class MyClass
{
   var[a]
   {
      get  {
         Return this._var[a]
      }
      
      set  {
         Return this._var[a] := value
      }
   }
}
MyClass.var[1] := &quot;first&quot;
MyClass.var[2] := &quot;second&quot;

MsgBox, % MyClass.var[1] . &quot;`n&quot; . MyClass.var[2]</code></pre></div>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2018-10-23T17:26:45Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=129402#p129402</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Проблема class proretries object array]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=129401#p129401" />
			<content type="html"><![CDATA[<p><strong>teadrinker</strong> спасибо, ваш способ работает.<br />А вот мои изыскания<br /></p><div class="codebox"><pre><code>
class MyClass
{
   var[]
   {
      get  {
         Return this._var
      }
      
      set  {
         Return this._var := value
      }
   }
}
MyClass.var := [&quot;first&quot;, &quot;second&quot;]
MsgBox, % MyClass.var.1 MyClass.var.2
MsgBox, % MyClass.var[&quot;_&quot;][1] MyClass.var[&quot;_&quot;][2]
</code></pre></div><p>Не очевидное поведение и в документации тоже таких примеров нет, попробуй догадайся.</p>]]></content>
			<author>
				<name><![CDATA[upsi_daezium]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=34120</uri>
			</author>
			<updated>2018-10-23T17:16:49Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=129401#p129401</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Проблема class proretries object array]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=129397#p129397" />
			<content type="html"><![CDATA[<div class="codebox"><pre><code>class MyClass
{
   var[]
   {
      get  {
         Return this._var
      }
      
      set  {
         Return this._var := value
      }
   }
}
MyClass.var := [&quot;first&quot;, &quot;second&quot;]
MsgBox, % MyClass.var.1
</code></pre></div>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2018-10-23T15:48:08Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=129397#p129397</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Проблема class proretries object array]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=129394#p129394" />
			<content type="html"><![CDATA[<p>А что не понятно-то?<br />Вот следующий шаг вы get set для свойтва напишите.</p>]]></content>
			<author>
				<name><![CDATA[upsi_daezium]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=34120</uri>
			</author>
			<updated>2018-10-23T14:46:21Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=129394#p129394</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Проблема class proretries object array]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=129390#p129390" />
			<content type="html"><![CDATA[<p>Я вашу запись не понимаю. Обратиться к свойству класса, которое массив:<br /></p><div class="codebox"><pre><code>class MyClass
{
   static var := [1, 2, 3]
}
MsgBox, % MyClass.var[1]</code></pre></div>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2018-10-23T14:22:31Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=129390#p129390</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Проблема class proretries object array]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=129389#p129389" />
			<content type="html"><![CDATA[<p><strong>teadrinker</strong> извиняюсь, код чисто для примера.<br />Проблема состоит в обращении к property класса, если это массив или обьект. Как правильно записать чтобы корректно работало:<br /></p><div class="codebox"><pre><code>
msgbox, % &quot;Array property2 will not display`n property1=&quot;t.pS &quot;`n property2=&quot; t.pA[1] t.pA[2] t.pA[3]
</code></pre></div>]]></content>
			<author>
				<name><![CDATA[upsi_daezium]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=34120</uri>
			</author>
			<updated>2018-10-23T14:17:16Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=129389#p129389</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Проблема class proretries object array]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=129386#p129386" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>upsi_daezium пишет:</cite><blockquote><p>Вот пример, чтобы видно было, че как</p></blockquote></div><p>Честно говоря, ничо не видно. <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /> Опишите лучше на словах, в чём проблема, и какого поведения хотите добиться.</p><div class="quotebox"><cite>upsi_daezium пишет:</cite><blockquote><p>&quot;Array property2 will not display`n property1=&quot;t.pS</p></blockquote></div><p>Между строкой и выражением вслед за ней лучше использовать пробелы или даже знак конкатенции, а то кровь из глаз.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2018-10-23T14:13:24Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=129386#p129386</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK: Проблема class proretries object array]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=129378#p129378" />
			<content type="html"><![CDATA[<p>Вот пример, чтобы видно было, че как. Проблема со свойствами класса, если свойтво обьект. <br /></p><div class="codebox"><pre><code>
arr := [&quot;one &quot;, &quot;two &quot;, &quot;three &quot;]
str := &quot;testing...&quot;

t := new Test(arr, str)
msgbox, % &quot;Array property2 will not display`n property1=&quot; t.pS &quot;`n property2=&quot; t.pA[1] t.pA[2] t.pA[3]
msgbox, % &quot;This works`n property1=&quot; t._pS &quot;`n property2=&quot; t._pA[1] t._pA[2] t._pA[3]
t.pS := &quot;none &quot;
MsgBox, % t.pS &quot; &quot; t._pS 
t._pS := &quot;something&quot;
MsgBox, % t.pS &quot; &quot; t._pS

Class Test {
	pA {
		get { 
			return this._pA
		}
		set {
			this._pA := value
			;this.Insert(value)
			return value
		}
	}

	pS {
		get { 
			return this._pS
		}
		set {
			this._pS := value . &quot;:)&quot;

			return value
		}	
	}

	__New(Array, String) {
		this.pA := Array
		this.pS := String
		;MsgBox, % pS

	}
}

</code></pre></div>]]></content>
			<author>
				<name><![CDATA[upsi_daezium]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=34120</uri>
			</author>
			<updated>2018-10-23T10:49:57Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=129378#p129378</id>
		</entry>
</feed>
