<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK: array.base]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=16069&amp;type=atom" />
	<updated>2021-02-10T10:04:31Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=16069</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: array.base]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=146112#p146112" />
			<content type="html"><![CDATA[<p>Не знаю, наверно никак.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2021-02-10T10:04:31Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=146112#p146112</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: array.base]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=146105#p146105" />
			<content type="html"><![CDATA[<p>А если допустим я буду использовать только ее, как ее &quot;починить&quot;? Метод выше не очень устраивает.</p>]]></content>
			<author>
				<name><![CDATA[Phoenixxx_Czar]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=34426</uri>
			</author>
			<updated>2021-02-10T02:55:54Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=146105#p146105</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: array.base]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=146069#p146069" />
			<content type="html"><![CDATA[<p>Думаю, что переопределять все объекты в скрипте не очень хорошая идея. Представьте, что вы используете несколько библиотек, где каждый автор переопределяет их на свой лад. Или наоборот, вы можете своим переопределением испортить работу объектов, авторы которых не рассчитывали на подобное.<br />Лучше изменять, если нужно, конкретные объекты:<br /></p><div class="codebox"><pre><code>arr := StrSplit(&quot;1 2 3 4 5 6&quot;, &quot; &quot;)
arr.base := _Array
newArr := arr.slice(3)

for k, v in newArr
   str .= (k = 1 ? &quot;&quot; : &quot;, &quot;) . v
MsgBox, % str

class _Array
{
   slice(start:=0, end:=0)
   {

      len := this.Length()

      ; START: Adjust 1 based index, check signage, set defaults
      if (start &gt; 0)
         begin := start - 1   ; Include starting index going forward
      else if (start &lt; 0)
         begin := len + start  ; Count backwards from end
      else
         begin := start


      ; END: Check signage and set defaults
      ; MDN States: &quot;to end (end not included)&quot; so subtract one from end
      if (end &gt; 0)
         last := end - 1
      else if (end &lt; 0)
         last := len + end + 1 ; Count backwards from end
      else
         last := len


      results := []

      loop, % last - begin
         results.push(this[begin + A_Index])

      return results
   }
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2021-02-09T14:19:24Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=146069#p146069</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK: array.base]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=146067#p146067" />
			<content type="html"><![CDATA[<p>Давненько нашел на просторах интернета, библиотеку, которая переносит JS функции в AHK. Там что-то подобное..</p><div class="codebox"><pre><code>Array(prms*)
{
	prms.base := _Array
	return prms
}

class _Array
{
	slice(start:=0, end:=0)
	{

		len := this.Length()

		; START: Adjust 1 based index, check signage, set defaults
		if (start &gt; 0)
			begin := start - 1	; Include starting index going forward
		else if (start &lt; 0)
			begin := len + start  ; Count backwards from end
		else
			begin := start


		; END: Check signage and set defaults
		; MDN States: &quot;to end (end not included)&quot; so subtract one from end
		if (end &gt; 0)
			last := end - 1
		else if (end &lt; 0)
			last := len + end + 1 ; Count backwards from end
		else
			last := len


		results := []

		loop, % last - begin
			results.push(this[begin + A_Index])

		return results
	}
}</code></pre></div><p>Вроде все работает, если сделать допустим так:<br /></p><div class="codebox"><pre><code>arr := [1, 2, 3, 4, 5, 6]
newArr := arr.slice(3) // [3, 4, 5, 6]</code></pre></div><p>Но это не работает вот так:<br /></p><div class="codebox"><pre><code>arr := StrSplit(&quot;1 2 3 4 5 6&quot;, &quot; &quot;)
newArr := arr.slice(3) // []</code></pre></div><p>К тому же это все нельзя было применить к Object.</p>]]></content>
			<author>
				<name><![CDATA[Phoenixxx_Czar]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=34426</uri>
			</author>
			<updated>2021-02-09T12:56:04Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=146067#p146067</id>
		</entry>
</feed>
