<?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=7417&amp;type=atom" />
	<updated>2012-09-09T13:29:53Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=7417</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Циклически изменять хоткеем значение буквенной переменной]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=63680#p63680" />
			<content type="html"><![CDATA[<p>Да, действительно, что-то я запамятовал, сорри.</p><br /><p><span class="postimg"><img src="http://s019.radikal.ru/i606/1203/58/7b55e7d0f1c8.jpg" alt="http://s019.radikal.ru/i606/1203/58/7b55e7d0f1c8.jpg" /></span></p>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2012-09-09T13:29:53Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=63680#p63680</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Циклически изменять хоткеем значение буквенной переменной]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=63679#p63679" />
			<content type="html"><![CDATA[<p><a href="http://forum.script-coding.com/viewtopic.php?pid=63400#p63400">1</a>, <a href="http://forum.script-coding.com/viewtopic.php?pid=63404#p63404">2</a> и внезапно <a href="http://forum.script-coding.com/viewtopic.php?pid=63406#p63406">3</a><br /></p><div class="codebox"><pre><code>List := {&quot;Стакан&quot;: &quot;Стеклянный&quot;, &quot;Вилка&quot;: &quot;Железная&quot;, &quot;Ложка&quot;: &quot;Деревянная&quot;}
result := ObjSearchValue(List, &quot;Железная&quot;))
msgbox % &quot;Совпадений: &quot; result.MaxIndex() &quot;`nПервое совпадение: &quot; result[1]
 
ObjSearchValue(obj, value)
{
    result := []
    for k, v in obj
        (v = value) &amp;&amp; result.Insert(k)
    return result
}</code></pre></div><div class="codebox"><pre><code>b1 := [&quot;Ложка&quot;,&quot;Вилка&quot;,&quot;Тарелка&quot;, &quot;Вилка&quot;,&quot;Вилка&quot;,&quot;Вилка&quot;,&quot;Вилка&quot;,&quot;Вилка&quot;,&quot;Вилка&quot;]

If IsObject(result := ObjSearchValue(b1, &quot;Вилка&quot;))
    msgbox % &quot;Совпадений: &quot; result.MaxIndex() &quot;`nПервое совпадение: &quot; result[1]

ObjSearchValue(obj, value)
{
    result := []
    for k, v in obj
        (v = value) &amp;&amp; result.Insert(k)
    return result.MaxIndex()? result : false
}</code></pre></div><p>Массивы List и b1 — объекты, в первом значения ассоциированы с текстовыми строками, во втором — с числами. Инициализация объекта с использованием {} или [] — для удобства, но суть объекта от этого не меняется.</p>]]></content>
			<author>
				<name><![CDATA[creature.ws]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26105</uri>
			</author>
			<updated>2012-09-09T13:23:17Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=63679#p63679</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Циклически изменять хоткеем значение буквенной переменной]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=63678#p63678" />
			<content type="html"><![CDATA[<p>Спасибо! А как сделать, чтобы если нет совпадения, то можно было это узнать, при подставлении не существующей в списке переменной, выдаёт 3.</p>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2012-09-09T13:18:52Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=63678#p63678</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Циклически изменять хоткеем значение буквенной переменной]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=63677#p63677" />
			<content type="html"><![CDATA[<div class="codebox"><pre><code>b1 := [&quot;Ложка&quot;,&quot;Вилка&quot;,&quot;Тарелка&quot;]

Space::
    Active := &quot;Вилка&quot;
    For a1, value in b1
        continue
    Until value = Active
    MsgBox % a1</code></pre></div>]]></content>
			<author>
				<name><![CDATA[creature.ws]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26105</uri>
			</author>
			<updated>2012-09-09T13:08:52Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=63677#p63677</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Циклически изменять хоткеем значение буквенной переменной]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=63676#p63676" />
			<content type="html"><![CDATA[<div class="codebox"><pre><code>b1 := [&quot;Ложка&quot;,&quot;Вилка&quot;,&quot;Тарелка&quot;]
a1 := 1
Active := b1[a1 :=  (!a1) ||  (a1&gt;=b1.MaxIndex()) ? 1 : a1+1]
Return
Space::
Active := &quot;Вилка&quot;
MsgBox %a1%</code></pre></div><p>Подскажите, а как здесь узнать значение &quot;a1&quot;. То есть например переменная стала равна &quot;Вилка&quot;, как узнать что она вторая в списке (получить на выходе &quot;2&quot;)?</p>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2012-09-09T12:56:39Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=63676#p63676</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Циклически изменять хоткеем значение буквенной переменной]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=62299#p62299" />
			<content type="html"><![CDATA[<p>Отголосок предыдущего кода, когда значение переменной <strong>a1</strong> было неопределено вначале. В данном случае есть явное <strong>a1 := 1</strong>, поэтому <strong>(!a1) ||</strong> как бы и не нужно.<br />Но кто гарантирует, что оно будут всегда? FoolFroofed код всегда лучше, чем обычный. <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /></p><p>Upd: Ну вот, и сам прекрасно разобрался. <img src="//forum.script-coding.com/img/smilies/wink.png" width="15" height="15" /></p>]]></content>
			<author>
				<name><![CDATA[Irbis]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27384</uri>
			</author>
			<updated>2012-08-03T08:52:23Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=62299#p62299</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Циклически изменять хоткеем значение буквенной переменной]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=62298#p62298" />
			<content type="html"><![CDATA[<p>Как ногам не дает покоя дурная голова, так оной не дает покоя вредная привычка читать темы, начиная с последних постов <img src="//forum.script-coding.com/img/smilies/big_smile.png" width="15" height="15" /> .<br /><a href="http://forum.script-coding.com/viewtopic.php?pid=61964#p61964">Начиналось-то</a> все с однострочного скрипта<br /></p><div class="codebox"><pre><code>F2:: a := (!a) ||  (a&gt;=3) ? 1 : a+1</code></pre></div><p>, откуда, видимо и перекочевало упомянутое мной условие в последующие, расширенные варианты.<br />Но все-таки хотелось бы знать точно, а то мерзкое ощущение не проходит <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" />.</p>]]></content>
			<author>
				<name><![CDATA[Korobkof]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=28148</uri>
			</author>
			<updated>2012-08-03T08:52:06Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=62298#p62298</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Циклически изменять хоткеем значение буквенной переменной]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=62297#p62297" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Irbis пишет:</cite><blockquote><div class="codebox"><pre><code>b1 := [&quot;Ложка&quot;,&quot;Вилка&quot;,&quot;Тарелка&quot;]
a1 := 1
Active := b1[a1] 
F1:: Active := b1[a1 :=  (!a1) ||  (a1&gt;=b1.MaxIndex()) ? 1 : a1+1]
F12::  MsgBox,,, %Active% , 1</code></pre></div></blockquote></div><p>Больше часа уже убил, мой ГГМ на грани выкипания, помогите!<br />Я не понимаю в данном примере назначения <br /></p><div class="codebox"><pre><code>(!a1) ||</code></pre></div><p>Вроде как а1 принимает значения от 1 до 3, то есть (!a1) всегда будет False? (Или нет? Если убрать (!a1) || - все работает.)<br />При отсутствии<br /></p><div class="codebox"><pre><code>
a1 := 1
Active := b1[a1]</code></pre></div><p>не улавливаемый мной смысл вроде как проявляется - значение по умолчанию тогда отсутствует и при первом нажатии хоткея нужно пустой переменной присвоить значение 1, чтобы начать перебор элементов массива с первого.<br />Разрешите мои сомнения пожалуйста, а то не покидает паскудное ощущение, что, упершись рогами, я в очередной раз упустил что-то очевидное <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" />.</p>]]></content>
			<author>
				<name><![CDATA[Korobkof]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=28148</uri>
			</author>
			<updated>2012-08-03T08:39:02Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=62297#p62297</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Циклически изменять хоткеем значение буквенной переменной]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=62292#p62292" />
			<content type="html"><![CDATA[<p>СПАСИБО!!!<br />Выручаете который раз!</p><p>Эх, когда же я в этом начну хоть что то понимать&nbsp; <img src="//forum.script-coding.com/img/smilies/sad.png" width="15" height="15" /></p>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2012-08-02T22:19:35Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=62292#p62292</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Циклически изменять хоткеем значение буквенной переменной]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=62291#p62291" />
			<content type="html"><![CDATA[<div class="codebox"><pre><code>b1 := [&quot;Ложка&quot;,&quot;Вилка&quot;,&quot;Тарелка&quot;]
a1 := 1
Active := b1[a1] 

F1:: Active := b1[a1 :=  (!a1) ||  (a1&gt;=b1.MaxIndex()) ? 1 : a1+1]
 
F12::  MsgBox,,, %Active% , 1</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Irbis]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27384</uri>
			</author>
			<updated>2012-08-02T22:16:07Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=62291#p62291</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Циклически изменять хоткеем значение буквенной переменной]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=62290#p62290" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Irbis пишет:</cite><blockquote><p>Мьсе страдает склерозом? <img src="//forum.script-coding.com/img/smilies/hmm.png" width="15" height="15" /> <a href="http://forum.script-coding.com/viewtopic.php?pid=61964#p61964">Пост</a></p></blockquote></div><p>Напротив хорошо помню&nbsp; <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /></p><p>Просто нет понимания как это связать именно с буквенной переменной.</p>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2012-08-02T22:13:03Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=62290#p62290</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Циклически изменять хоткеем значение буквенной переменной]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=62289#p62289" />
			<content type="html"><![CDATA[<p>Мьсе страдает склерозом? <img src="//forum.script-coding.com/img/smilies/hmm.png" width="15" height="15" /> <a href="http://forum.script-coding.com/viewtopic.php?pid=61964#p61964">Пост</a></p><p>(Тонкий намек - элементами списка могут быть не только числа.)</p>]]></content>
			<author>
				<name><![CDATA[Irbis]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27384</uri>
			</author>
			<updated>2012-08-02T22:08:49Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=62289#p62289</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK: Циклически изменять хоткеем значение буквенной переменной]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=62286#p62286" />
			<content type="html"><![CDATA[<p>Господа подскажите чайнику как проще циклически изменять одним хоткеем значение буквенной переменной.<br />Всё до чего мог додуматся:<br /></p><div class="codebox"><pre><code>A = Вилка

F3::MsgBox %A%
return

F2::
If A = Вилка
{
A = Ложка  
return
} 
Else
If A = Ложка
{
A = Тарелка  
return
} 
Else
A = Вилка 
return</code></pre></div><p>УЖАС <img src="//forum.script-coding.com/img/smilies/lol.png" width="15" height="15" /></p>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2012-08-02T21:45:16Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=62286#p62286</id>
		</entry>
</feed>
