<?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=12399&amp;type=atom" />
	<updated>2017-02-04T16:45:19Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=12399</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Значения из переменной в разные переменные]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=111878#p111878" />
			<content type="html"><![CDATA[<p>Угу, окей, давайте дальше. Ответ получается, к примеру - 5. Теперь нужно обратно перевести это значение в букву. Представим, что переменная kkk имеет значение 5. По таблице получается, что 5 это В. Как сделать, чтобы MsgBох выдавал не 5, а B?</p>]]></content>
			<author>
				<name><![CDATA[Alex_Lexon]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=32135</uri>
			</author>
			<updated>2017-02-04T16:45:19Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=111878#p111878</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Значения из переменной в разные переменные]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=111832#p111832" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>stealzy пишет:</cite><blockquote><p>В условии так-то не сказано, что входящие данные неправильные.</p></blockquote></div><p>Как и про обратное. И зачем тогда?</p><div class="codebox"><pre><code>else if arr[a]</code></pre></div><div class="codebox"><pre><code>MsgBox %a% Not Found</code></pre></div><div class="quotebox"><cite>stealzy пишет:</cite><blockquote><p>Не вижу причин считать любую распарсенную переменную равной нулю, если для нее явно не задано значение.</p></blockquote></div><p>Также как и до этого совершенно не понимаю, о чём речь...</p><div class="quotebox"><cite>stealzy пишет:</cite><blockquote><p>И две запятых подряд в строке - лучше предупредить. Или не в этом ошибка?</p></blockquote></div><p>Про две запятых не понял. Ошибка как я посчитал в том, что раз уже проверка значения ключа массива в коде есть, то это указывает на то, что автор кода предполагает вероятность неверных данных, тогда например так:<br /></p><div class="codebox"><pre><code>arr := {red: 11, A: 22, &quot;B+&quot;: 44}
Colors := &quot;red, A, B+, C, 5, 7&quot; </code></pre></div><p>или так</p><div class="codebox"><pre><code>arr := {red: 11, A: 22, &quot;B+&quot;: &quot;text&quot;}
Colors := &quot;red, A, B+, 5, 7&quot;</code></pre></div><p>будет неправильный результат.</p>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2017-02-03T23:30:36Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=111832#p111832</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Значения из переменной в разные переменные]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=111831#p111831" />
			<content type="html"><![CDATA[<p>В условии так-то не сказано, что входящие данные неправильные.<br />Не вижу причин считать любую распарсенную переменную равной нулю, если для нее явно не задано значение. И две запятых подряд в строке - лучше предупредить. Или не в этом ошибка?</p>]]></content>
			<author>
				<name><![CDATA[stealzy]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=31937</uri>
			</author>
			<updated>2017-02-03T23:12:42Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=111831#p111831</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Значения из переменной в разные переменные]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=111830#p111830" />
			<content type="html"><![CDATA[<p>В предыдущем посте в код добавлена проверка, что переменная имеет значение.<br /><strong>stealzy</strong> в 6 посте на этот счёт есть пара ошибок.</p><p>Если с переменными, то так правильнее:<br /></p><div class="codebox"><pre><code>
A := 3, A# := 5, C := 8 
str := &quot;A, A+, C, 7, 5&quot;
 
Loop, parse, % StrReplace(str, &quot;+&quot;, &quot;#&quot;), `,, % A_Space, Sum := Co := 0
	# := A_LoopField, (# + 0 != &quot;&quot; &amp;&amp; (++Co, Sum += #)) || (%#% + 0 != &quot;&quot; &amp;&amp; (++Co, Sum += %#%)) 
MsgBox % Sum / Co
</code></pre></div><p>Вместо плюса, в имени переменной &quot;#&quot;.</p>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2017-02-03T21:49:05Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=111830#p111830</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Значения из переменной в разные переменные]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=111829#p111829" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>stealzy пишет:</cite><blockquote><p>Я тоже сначала тернарный использовал.</p></blockquote></div><p>Можно и без тернарного. <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /><br /></p><div class="codebox"><pre><code>
o := {A:3, &quot;A+&quot;:5, C:8} 
str := &quot;A, A+, C, 7, 5&quot; 

Loop, parse, str, `,, % A_Space, S := C := 0
	i := A_LoopField, (i + 0 != &quot;&quot; &amp;&amp; (++C, S += i)) || (o[i] + 0 != &quot;&quot; &amp;&amp; (++C, S += o[i])) 
MsgBox % S / C
</code></pre></div><div class="quotebox"><cite>stealzy пишет:</cite><blockquote><p>Читать большой скрипт с подобным кодом вообще тяжело.</p></blockquote></div><p>Думаю дело привычки, чем чаще используешь, тем проще читаешь.</p><div class="quotebox"><cite>stealzy пишет:</cite><blockquote><p>если ТС понадобиться произведение вместо суммы, он, я думаю не сразу дойдет, в чем подвох</p></blockquote></div><p>Пункта про простоту кода не было.</p><div class="quotebox"><cite>stealzy пишет:</cite><blockquote><p>И не инициализированные переменные считать равными нулю не факт, что можно.</p></blockquote></div><p>Тут не понял.</p>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2017-02-03T21:41:47Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=111829#p111829</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Значения из переменной в разные переменные]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=111828#p111828" />
			<content type="html"><![CDATA[<p>Я тоже сначала тернарный использовал. А потом подумал, что лучше написать длиннее но понятнее.<br />Читать большой скрипт с подобным кодом вообще тяжело.<br />Засунуть 0 в OmitChars это оригинально, если ТС понадобиться произведение вместо суммы, он, я думаю не сразу дойдет, в чем подвох&nbsp; :-). И не инициализированные переменные считать равными нулю не факт, что можно.</p>]]></content>
			<author>
				<name><![CDATA[stealzy]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=31937</uri>
			</author>
			<updated>2017-02-03T21:12:35Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=111828#p111828</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Значения из переменной в разные переменные]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=111827#p111827" />
			<content type="html"><![CDATA[<p>И с массивом несложно, просто в шапке про переменные написано.<br /></p><div class="codebox"><pre><code>
o := {A:3, &quot;A+&quot;:5, C:8} 
str := &quot;A, A+, C, 7, 5&quot;

Loop, parse, str, `,, % A_Space, sum := 0  
	Sum += (A_LoopField + 0 = &quot;&quot; ? o[A_LoopField] : A_LoopField), Count := A_Index
MsgBox % Sum / Count
</code></pre></div>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2017-02-03T21:08:59Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=111827#p111827</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Значения из переменной в разные переменные]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=111826#p111826" />
			<content type="html"><![CDATA[<p>Ну да. Хотя если переменных, кончающихся на p нет, то проще выходит.</p>]]></content>
			<author>
				<name><![CDATA[stealzy]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=31937</uri>
			</author>
			<updated>2017-02-03T21:07:25Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=111826#p111826</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Значения из переменной в разные переменные]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=111825#p111825" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>stealzy пишет:</cite><blockquote><p>действительно, достаточно взять в кавычки ключи массива.</p></blockquote></div><p>Про это?</p>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2017-02-03T21:02:17Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=111825#p111825</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Значения из переменной в разные переменные]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=111824#p111824" />
			<content type="html"><![CDATA[<p>Кто-то не обновил комментарии перед ответом ;-).</p>]]></content>
			<author>
				<name><![CDATA[stealzy]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=31937</uri>
			</author>
			<updated>2017-02-03T20:58:50Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=111824#p111824</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Значения из переменной в разные переменные]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=111823#p111823" />
			<content type="html"><![CDATA[<p>Помоему проще заменить на &quot;plus&quot;.<br /></p><div class="codebox"><pre><code>
A := 3, Ap := 5, C := 8 
str := &quot;A, A+, C, 7, 5&quot;
 
Loop, parse, % StrReplace(str, &quot;+&quot;, &quot;p&quot;), `,, % A_Space, sum := 0
	sum += (A_LoopField + 0 = &quot;&quot; ? %A_LoopField% : A_LoopField), Count := A_Index
MsgBox % sum / Count
</code></pre></div>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2017-02-03T20:56:25Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=111823#p111823</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Значения из переменной в разные переменные]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=111822#p111822" />
			<content type="html"><![CDATA[<p><strong>Malcev</strong>, действительно, достаточно взять в кавычки ключи массива.<br />Значит, вопрос решен.</p>]]></content>
			<author>
				<name><![CDATA[stealzy]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=31937</uri>
			</author>
			<updated>2017-02-03T20:52:45Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=111822#p111822</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Значения из переменной в разные переменные]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=111821#p111821" />
			<content type="html"><![CDATA[<div class="quotebox"><blockquote><p>Если же A и A+ это разные вещи, то замените &quot;+&quot; на &quot;plus&quot;, скажем.</p></blockquote></div><p>Зачем?</p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2017-02-03T20:49:24Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=111821#p111821</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Значения из переменной в разные переменные]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=111819#p111819" />
			<content type="html"><![CDATA[<div class="codebox"><pre><code>Colors := &quot;red, A, B+, 5, 7&quot;
arr := {red: 11, A: 22, &quot;B+&quot;: 44}
summ := 0

Loop, parse, Colors, `,,%A_Space%
{
	a := A_LoopField

	if a is number
		summ+=a
	else if arr[a]
		summ+=arr[a]
	else
		MsgBox %a% Not Found

	N:=A_Index
}
MsgBox % summ / N</code></pre></div>]]></content>
			<author>
				<name><![CDATA[stealzy]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=31937</uri>
			</author>
			<updated>2017-02-03T20:39:52Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=111819#p111819</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Значения из переменной в разные переменные]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=111818#p111818" />
			<content type="html"><![CDATA[<p>То есть сложить сумму указанных в строке переменных и чисел?</p>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2017-02-03T20:33:44Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=111818#p111818</id>
		</entry>
</feed>
