<?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=17179&amp;type=atom" />
	<updated>2022-06-15T08:36:15Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=17179</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Ассоциативный массив]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=153553#p153553" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>__Михаил__ пишет:</cite><blockquote><p>Скобки для ключа? Ни разу такое не встречал.</p></blockquote></div><p>Так можно даже в JS, только используются квадратные скобки:<br /></p><div class="codebox"><pre><code>
const key = &quot;test&quot;;
const obj = {[key]: &quot;value&quot;};

console.log(obj);
</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Phoenixxx_Czar]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=34426</uri>
			</author>
			<updated>2022-06-15T08:36:15Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=153553#p153553</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Ассоциативный массив]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=153547#p153547" />
			<content type="html"><![CDATA[<p>Вроде ничего сложного нет. Скобки для ключа? Ни разу такое не встречал.</p><div class="codebox"><pre><code>Arr := {}	; Создаём ассоциативный массив.
Key1 := 123, Var1 := &quot;Var 123&quot;
Key2 := &quot;987&quot;, Var2 := &quot;Var 987&quot;

Arr[Key1] := Var1
Arr[Key2] := Var2
Arr.Key3 := Key1 + Key2		; Вариант присвоения строки &#039;Key3&#039;. АХК игнорит строку и прибавляет как число.

For k,v in Arr{		; Обойти всё содержимое:
 T .= k &quot;`t=`t&quot; v &quot;`n&quot;	; Добавить в строку для отображения.
}
MsgBox, % Arr[Key1] &quot;`n&quot; Arr[Key2] &quot;`n`n&quot; T</code></pre></div>]]></content>
			<author>
				<name><![CDATA[__Михаил__]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=40928</uri>
			</author>
			<updated>2022-06-14T16:25:29Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=153547#p153547</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Ассоциативный массив]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=153546#p153546" />
			<content type="html"><![CDATA[<p>Извините, немного затупил, на официальном сайте нашёл:<br /></p><div class="codebox"><pre><code>
dir := {}
var := &quot;123&quot;
dir := {(var):&quot;456&quot;}
MsgBox, % dir[var]
</code></pre></div><p>Сразу не нашёл т.к. всё на английском, а на русском Wiki этого нету(либо я плохо искал).<br />Хотя если сделать так:<br /></p><div class="codebox"><pre><code>
dir := {}
var := &quot;123&quot;
dir := {(var):&quot;456&quot;}
MsgBox, % dir[&quot;123&quot;]
</code></pre></div><p>То всё равно не заработает и это странно т.к. с другой переменной в которой это же значение (&quot;123&quot;) будет всё работать.<br />Так что проблема решена!</p>]]></content>
			<author>
				<name><![CDATA[~incognito]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=41862</uri>
			</author>
			<updated>2022-06-14T15:48:59Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=153546#p153546</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK: Ассоциативный массив]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=153545#p153545" />
			<content type="html"><![CDATA[<p>Здравствуйте, не понимаю как внедрить в ассоциативный массив переменную:<br /></p><div class="codebox"><pre><code>
dir := {}
var := &quot;123&quot;
dir := { %var% :&quot;456&quot;}
MsgBox, % dir[&quot;123&quot;]
</code></pre></div><p>Это возвращает ошибку, а если просто сделать так:<br /></p><div class="codebox"><pre><code>
dir := {}
var := &quot;123&quot;
dir := {var:&quot;456&quot;}
MsgBox, % dir[&quot;123&quot;]
</code></pre></div><p>То ключом массива будет var, т.е dir.var</p>]]></content>
			<author>
				<name><![CDATA[~incognito]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=41862</uri>
			</author>
			<updated>2022-06-14T15:44:36Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=153545#p153545</id>
		</entry>
</feed>
