<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK: Как сделать чтобы действие производилось при 2 и более условиях?]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=13613&amp;type=atom" />
	<updated>2018-04-15T11:28:03Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=13613</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Как сделать чтобы действие производилось при 2 и более условиях?]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=124718#p124718" />
			<content type="html"><![CDATA[<div class="codebox"><pre><code>
limit := 10000
hr := 0, dPart := 0
data := [[&quot;Число&quot;,&quot;Значение&quot;]]
Loop,% limit {
	hundred := hr // 100 * 100
	unit := hr - hundred
	(unit  &gt; 24 &amp;&amp; dPart := unit // 10 * 10)
	str := (unit == 1 + dPart || unit == 21 + dPart) ? &quot;час&quot; : (unit &gt; 1 + dPart &amp;&amp; unit &lt; 5 + dPart) || (unit &gt; 21 + dPart &amp;&amp; unit &lt; 25 + dPart) ? &quot;часа&quot; : &quot;часов&quot;
	data.Push( [hr, str] ), hr++
}

Gui,1: Add,ListView,w200 h400 NoSort vLVval +LV0x00010000 +HwndLV_H,Число|Значение
Gui,1: Show,,Список
CreateTable(data, &quot;LVval&quot;)
return
CreateTable(tableArr,ctrlNameValue) {
	Gui, 1: ListView, %ctrlNameValue%
	GuiControl, -ReDraw, %ctrlNameValue%
	LV_Delete()
	Loop, % LV_GetCount(&quot;Column&quot;)
		LV_DeleteCol(1)
	Loop,% tableArr[1].Length()
		LV_InsertCol(A_Index,&quot;&quot;, tableArr[1][A_Index])
	Loop,% tableArr.Length()-1 {
		rNmbr := LV_Add(&quot;&quot;, &quot;&quot;)
		Loop,% cCount := tableArr[rNmbr+1].Length()
			LV_Modify(rNmbr, &quot;Col&quot; . A_Index,tableArr[rNmbr+1][A_Index])
	} Loop, % tableArr[1].Length()
		LV_ModifyCol(A_Index, &quot;AutoHdr&quot;)
	GuiControl, +ReDraw, %ctrlNameValue%
}
GuiClose:
	ExitApp
</code></pre></div><p><strong>UPD 1:</strong> Поправка на сотни.<br /><strong>UPD 2:</strong> Поспешишь, людей насмешишь.<br />Прошу прощения, так будет правильно:<br /></p><div class="codebox"><pre><code>
limit := 10000
hr := 0, dPart := 0
data := [[&quot;Число&quot;,&quot;Значение&quot;]]
Loop,% limit {
	unit := hr - (hr // 100 * 100)
	unit &gt; 20 ? dPart := unit // 10 * 10 : dPart := 0
	str := (unit == 1 + dPart) ? &quot;час&quot; : (unit &gt; 1 + dPart &amp;&amp; unit &lt; 5 + dPart) ? &quot;часа&quot; : &quot;часов&quot;
	data.Push( [hr, str] ), hr++
}

Gui,1: Add,ListView,w200 h400 NoSort vLVval +LV0x00010000 +HwndLV_H,Число|Значение
Gui,1: Show,,Список
CreateTable(data, &quot;LVval&quot;)
return
CreateTable(tableArr,ctrlNameValue) {
	Gui, 1: ListView, %ctrlNameValue%
	GuiControl, -ReDraw, %ctrlNameValue%
	LV_Delete()
	Loop, % LV_GetCount(&quot;Column&quot;)
		LV_DeleteCol(1)
	Loop,% tableArr[1].Length()
		LV_InsertCol(A_Index,&quot;&quot;, tableArr[1][A_Index])
	Loop,% tableArr.Length()-1 {
		rNmbr := LV_Add(&quot;&quot;, &quot;&quot;)
		Loop,% cCount := tableArr[rNmbr+1].Length()
			LV_Modify(rNmbr, &quot;Col&quot; . A_Index,tableArr[rNmbr+1][A_Index])
	} Loop, % tableArr[1].Length()
		LV_ModifyCol(A_Index, &quot;AutoHdr&quot;)
	GuiControl, +ReDraw, %ctrlNameValue%
}
GuiClose:
	ExitApp
</code></pre></div>]]></content>
			<author>
				<name><![CDATA[KusochekDobra]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=33846</uri>
			</author>
			<updated>2018-04-15T11:28:03Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=124718#p124718</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Как сделать чтобы действие производилось при 2 и более условиях?]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=124711#p124711" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>KusochekDobra пишет:</cite><blockquote><div class="codebox"><pre><code>
hr := 1

if (hr == 1 || hr == 21)
	str := &quot;час&quot;
else if (hr &gt; 1 &amp;&amp; hr &lt; 5) || (hr &gt; 21 &amp;&amp; hr &lt; 24)
	str := &quot;часа&quot;
else
	str := &quot;часов&quot;
MsgBox,,Время,% hr &quot; &quot; str
</code></pre></div></blockquote></div><p>Есть ли такой же вариант склонений для больших чисел — тысяч до 10 хотя бы?</p>]]></content>
			<author>
				<name><![CDATA[DD]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=25263</uri>
			</author>
			<updated>2018-04-15T07:58:52Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=124711#p124711</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Как сделать чтобы действие производилось при 2 и более условиях?]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=124566#p124566" />
			<content type="html"><![CDATA[<p><strong>KusochekDobra</strong><br />Спасибо большое.<br />p.s. справку я прочитал</p>]]></content>
			<author>
				<name><![CDATA[Chikko]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=39127</uri>
			</author>
			<updated>2018-04-09T16:27:23Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=124566#p124566</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Как сделать чтобы действие производилось при 2 и более условиях?]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=124565#p124565" />
			<content type="html"><![CDATA[<div class="codebox"><pre><code>
#Persistent
SetTimer, sch, 1000
Return

sch:
if(A_Hour &gt;= 19 &amp;&amp; A_Hour &lt; 20)
{
    Run C:\Users\Home\Desktop
    ExitApp
}
Return
</code></pre></div>]]></content>
			<author>
				<name><![CDATA[rowe]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=33506</uri>
			</author>
			<updated>2018-04-09T16:23:28Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=124565#p124565</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Как сделать чтобы действие производилось при 2 и более условиях?]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=124564#p124564" />
			<content type="html"><![CDATA[<p>if -&gt; else:<br /></p><div class="codebox"><pre><code>
hr := 1

if (hr == 1 || hr == 21)
	str := &quot;час&quot;
else if (hr &gt; 1 &amp;&amp; hr &lt; 5) || (hr &gt; 21 &amp;&amp; hr &lt; 24)
	str := &quot;часа&quot;
else
	str := &quot;часов&quot;
MsgBox,,Время,% hr &quot; &quot; str
</code></pre></div><p>Тернарный эквивалент:<br /></p><div class="codebox"><pre><code>
hr := 1
str := (hr == 1 || hr == 21) ? &quot;час&quot; : (hr &gt; 1 &amp;&amp; hr &lt; 5) || (hr &gt; 21 &amp;&amp; hr &lt; 24) ? &quot;часа&quot; : &quot;часов&quot;
MsgBox,,Время,% hr &quot; &quot; str
</code></pre></div><p>Проверить 24 часовой ряд:<br /></p><div class="codebox"><pre><code>
hr := 0
Loop 24 {
	str := (hr == 1 || hr == 21) ? &quot;час&quot; : (hr &gt; 1 &amp;&amp; hr &lt; 5) || (hr &gt; 21 &amp;&amp; hr &lt; 24) ? &quot;часа&quot; : &quot;часов&quot;
	MsgBox,,Время,% hr++ &quot; &quot; str
}
</code></pre></div>]]></content>
			<author>
				<name><![CDATA[KusochekDobra]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=33846</uri>
			</author>
			<updated>2018-04-09T16:01:58Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=124564#p124564</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Как сделать чтобы действие производилось при 2 и более условиях?]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=124563#p124563" />
			<content type="html"><![CDATA[<p>Справку читали?</p>]]></content>
			<author>
				<name><![CDATA[KusochekDobra]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=33846</uri>
			</author>
			<updated>2018-04-09T15:41:24Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=124563#p124563</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Как сделать чтобы действие производилось при 2 и более условиях?]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=124562#p124562" />
			<content type="html"><![CDATA[<p><strong>KusochekDobra</strong><br />Вы наверное неправильно меня поняли. Я написал, что нужно это всё как-то поместить в If. Приведу другой пример.<br />Если на компьютере 11, 12, или 13 часОВ времени, то переменная var будет равна &quot;часов&quot;<br />А если же на компьютере 21 или 1 чаС времени, то переменная var будет равна &quot;час&quot;<br />Но я хочу как-то уместить все эти условия в одной строчке команды If<br /></p><div class="codebox"><pre><code>If(A_Hour=11,12,13)
{
var= часов
}
Else If(A_Hour=21,1)
{
var= час
}
</code></pre></div><p>Можно ли вообще поместить несколько условий в одних скобочках команды If</p>]]></content>
			<author>
				<name><![CDATA[Chikko]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=39127</uri>
			</author>
			<updated>2018-04-09T15:37:19Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=124562#p124562</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Как сделать чтобы действие производилось при 2 и более условиях?]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=124561#p124561" />
			<content type="html"><![CDATA[<p>Чтобы понимать, как происходит логическое описание, для этого нужно почитать соответствующую литературу, или обратиться к <a href="http://www.script-coding.com/AutoHotkey/Variables.1.0.46.07.html">справке</a>. Но то, как Вы описываете задачу, может быть решено следующим:<br /></p><div class="codebox"><pre><code>
r::
g::
b::
	MsgBox RGB
return

h::
s::
v::
	MsgBox HSV
return
</code></pre></div>]]></content>
			<author>
				<name><![CDATA[KusochekDobra]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=33846</uri>
			</author>
			<updated>2018-04-09T15:18:27Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=124561#p124561</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK: Как сделать чтобы действие производилось при 2 и более условиях?]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=124557#p124557" />
			<content type="html"><![CDATA[<p>Допустим, если я нажму клавишу R, G, или B то откроется MsgBox с надписью &quot;RGB&quot;.</p><p>А если я нажму H, S, или V, то откроется MsgBox с надписью &quot;HSV&quot;.</p><p>Мне надо всё это как-то поместить в If.</p>]]></content>
			<author>
				<name><![CDATA[Chikko]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=39127</uri>
			</author>
			<updated>2018-04-09T13:12:44Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=124557#p124557</id>
		</entry>
</feed>
