<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK: Проблема с массивом в объекте класса]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=11959&amp;type=atom" />
	<updated>2016-08-29T13:54:41Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=11959</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Проблема с массивом в объекте класса]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=107139#p107139" />
			<content type="html"><![CDATA[<p>Благодарю. Я крайне глупый человек.</p>]]></content>
			<author>
				<name><![CDATA[John_Science]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=33318</uri>
			</author>
			<updated>2016-08-29T13:54:41Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=107139#p107139</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Проблема с массивом в объекте класса]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=107138#p107138" />
			<content type="html"><![CDATA[<p><strong>teadrinker</strong><br />Простите. Не тот файл скопировал.</p>]]></content>
			<author>
				<name><![CDATA[John_Science]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=33318</uri>
			</author>
			<updated>2016-08-29T13:51:13Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=107138#p107138</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Проблема с массивом в объекте класса]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=107137#p107137" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>John_Science пишет:</cite><blockquote><div class="codebox"><pre><code>this.cells.Push(var)</code></pre></div></blockquote></div><p>А откуда там <em>var</em> взялась и чему она равна?</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2016-08-29T13:44:10Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=107137#p107137</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK: Проблема с массивом в объекте класса]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=107134#p107134" />
			<content type="html"><![CDATA[<p>Я реализовал самый простейший класс ограниченной очереди, однако ,вопреки моим ожиданиям, он не заработал.<br />После недолгих разбирательств я обнаружил, что проблема возникает тогда, когда я обращаюсь к элементам массива-свойству моего объекта.</p><p>Вот код:<br /></p><div class="codebox"><pre><code>class LimitedQueue
{	
	__New()
	{
		this.size := 3
		this.cells := Array()
	}
	
	addElement(element)
	{
		if (this.cells.MaxIndex() &lt; this.size)
		{
			this.cells.Push(var)
		}
		else
		{
			Loop, % this.size - 1
				this.cells[A_Index] := this.cells[A_Index + 1]
			this.cells[this.size] := var
		}
	}
	
	Display()
	{
		arr := this.cells
		Loop, % arr.MaxIndex()
		{
			s := arr[A_Index]
			Display(%s%)
		}
	}
}

Display(s)
{
	MsgBox, %s%
}

obj := new LimitedQueue()

obj.addElement(&quot;Hello world&quot;)
obj.addElement(&quot;Hello world&quot;)
obj.addElement(&quot;Hello world&quot;)
Display(obj.cells[1])</code></pre></div><br /><p>Я предполагаю с чем это связано. Я слышал, что нельзя объявлять псевдо-массивы в функции, однако не знал, как это работает по отношению к массивам, созданным функцией Array(). Если это так, то какие элегантные варианты решения проблемы вы могли бы мне посоветовать? Также было бы интересно</p>]]></content>
			<author>
				<name><![CDATA[John_Science]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=33318</uri>
			</author>
			<updated>2016-08-29T12:51:10Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=107134#p107134</id>
		</entry>
</feed>
