<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK: Приближение значения 1 переменной к другой при сравнении.]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=15026&amp;type=atom" />
	<updated>2019-10-20T06:10:27Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=15026</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Приближение значения 1 переменной к другой при сравнении.]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=136414#p136414" />
			<content type="html"><![CDATA[<p>Как-то так:<br /></p><div class="codebox"><pre><code>routes := {&quot;00:00:00&quot;: &quot;101&quot;, &quot;01:00:00&quot;: &quot;103&quot;, &quot;02:00:00&quot;: &quot;105&quot;, &quot;03:00:00&quot;: &quot;107&quot;, &quot;04:00:00&quot;: &quot;109&quot;, &quot;05:00:00&quot;: &quot;111&quot;, &quot;06:00:00&quot;: &quot;113&quot;, &quot;07:00:00&quot;: &quot;115&quot;, &quot;07:20:00&quot;: &quot;117&quot;, &quot;07:40:00&quot;: &quot;119&quot;, &quot;08:00:00&quot;: &quot;121&quot;, &quot;08:20:00&quot;: &quot;123&quot;, &quot;08:40:00&quot;: &quot;125&quot;, &quot;09:00:00&quot;: &quot;127&quot;, &quot;09:20:00&quot;: &quot;129&quot;, &quot;09:40:00&quot;: &quot;131&quot;, &quot;10:00:00&quot;: &quot;133&quot;, &quot;10:20:00&quot;: &quot;135&quot;, &quot;10:40:00&quot;: &quot;137&quot;, &quot;11:00:00&quot;: &quot;139&quot;, &quot;11:20:00&quot;: &quot;141&quot;, &quot;11:40:00&quot;: &quot;143&quot;, &quot;12:00:00&quot;: &quot;001&quot;, &quot;12:20:00&quot;: &quot;003&quot;, &quot;12:40:00&quot;: &quot;005&quot;, &quot;13:00:00&quot;: &quot;007&quot;, &quot;13:20:00&quot;: &quot;009&quot;, &quot;13:40:00&quot;: &quot;011&quot;, &quot;14:00:00&quot;: &quot;013&quot;, &quot;14:20:00&quot;: &quot;015&quot;, &quot;14:40:00&quot;: &quot;017&quot;, &quot;15:00:00&quot;: &quot;019&quot;, &quot;15:20:00&quot;: &quot;021&quot;, &quot;15:40:00&quot;: &quot;023&quot;, &quot;16:00:00&quot;: &quot;025&quot;, &quot;16:20:00&quot;: &quot;027&quot;, &quot;16:40:00&quot;: &quot;029&quot;, &quot;17:00:00&quot;: &quot;031&quot;, &quot;17:20:00&quot;: &quot;033&quot;, &quot;17:40:00&quot;: &quot;035&quot;, &quot;18:00:00&quot;: &quot;037&quot;, &quot;18:20:00&quot;: &quot;039&quot;, &quot;18:40:00&quot;: &quot;041&quot;, &quot;19:00:00&quot;: &quot;043&quot;, &quot;19:20:00&quot;: &quot;045&quot;, &quot;19:40:00&quot;: &quot;047&quot;, &quot;20:00:00&quot;: &quot;145&quot;, &quot;20:20:00&quot;: &quot;147&quot;, &quot;20:40:00&quot;: &quot;149&quot;, &quot;21:00:00&quot;: &quot;151&quot;, &quot;21:20:00&quot;: &quot;153&quot;, &quot;21:40:00&quot;: &quot;155&quot;, &quot;22:00:00&quot;: &quot;157&quot;, &quot;23:00:00&quot;: &quot;159&quot;, &quot;00:30:00&quot;: &quot;102&quot;, &quot;01:30:00&quot;: &quot;104&quot;, &quot;02:30:00&quot;: &quot;106&quot;, &quot;03:30:00&quot;: &quot;108&quot;, &quot;04:30:00&quot;: &quot;110&quot;, &quot;05:30:00&quot;: &quot;112&quot;, &quot;06:30:00&quot;: &quot;114&quot;, &quot;07:10:00&quot;: &quot;116&quot;, &quot;07:30:00&quot;: &quot;118&quot;, &quot;07:50:00&quot;: &quot;120&quot;, &quot;08:10:00&quot;: &quot;122&quot;, &quot;08:30:00&quot;: &quot;124&quot;, &quot;08:50:00&quot;: &quot;126&quot;, &quot;09:10:00&quot;: &quot;128&quot;, &quot;09:30:00&quot;: &quot;130&quot;, &quot;09:50:00&quot;: &quot;132&quot;, &quot;10:10:00&quot;: &quot;134&quot;, &quot;10:30:00&quot;: &quot;136&quot;, &quot;10:50:00&quot;: &quot;138&quot;, &quot;11:10:00&quot;: &quot;140&quot;, &quot;11:30:00&quot;: &quot;142&quot;, &quot;11:50:00&quot;: &quot;144&quot;, &quot;12:10:00&quot;: &quot;002&quot;, &quot;12:30:00&quot;: &quot;004&quot;, &quot;12:50:00&quot;: &quot;006&quot;, &quot;13:10:00&quot;: &quot;008&quot;, &quot;13:30:00&quot;: &quot;010&quot;, &quot;13:50:00&quot;: &quot;012&quot;, &quot;14:10:00&quot;: &quot;014&quot;, &quot;14:30:00&quot;: &quot;016&quot;, &quot;14:50:00&quot;: &quot;018&quot;, &quot;15:10:00&quot;: &quot;020&quot;, &quot;15:30:00&quot;: &quot;022&quot;, &quot;15:50:00&quot;: &quot;024&quot;, &quot;16:10:00&quot;: &quot;026&quot;, &quot;16:30:00&quot;: &quot;028&quot;, &quot;16:50:00&quot;: &quot;030&quot;, &quot;17:10:00&quot;: &quot;032&quot;, &quot;17:30:00&quot;: &quot;034&quot;, &quot;17:50:00&quot;: &quot;036&quot;, &quot;18:10:00&quot;: &quot;038&quot;, &quot;18:30:00&quot;: &quot;040&quot;, &quot;18:50:00&quot;: &quot;042&quot;, &quot;19:10:00&quot;: &quot;044&quot;, &quot;19:30:00&quot;: &quot;046&quot;, &quot;19:50:00&quot;: &quot;048&quot;, &quot;20:10:00&quot;: &quot;146&quot;, &quot;20:30:00&quot;: &quot;148&quot;, &quot;20:50:00&quot;: &quot;150&quot;, &quot;21:10:00&quot;: &quot;152&quot;, &quot;21:30:00&quot;: &quot;154&quot;, &quot;21:50:00&quot;: &quot;156&quot;, &quot;22:30:00&quot;: &quot;158&quot;, &quot;23:30:00&quot;: &quot;160&quot;}
FormatTime, routetime,, HHmmss
routetime := A_YYYY . A_MM . A_DD . routetime
prevDiff := 0xFFFFFFFF
for k, v in routes {
   if SubStr(routetime, 9, 2) = &quot;23&quot; &amp;&amp; k = &quot;00:00:00&quot;
      k := &quot;23:59:59&quot;
   time := A_YYYY . A_MM . A_DD . StrReplace(k, &quot;:&quot;)
   now := A_Now
   now -= time, s
   if (now &gt;= 0)
      continue
   diff := routetime
   diff -= time, s
   if ( Abs(diff) &lt; prevDiff )
      route := v, prevDiff := Abs(diff)
}
MsgBox, % route</code></pre></div>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2019-10-20T06:10:27Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=136414#p136414</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Приближение значения 1 переменной к другой при сравнении.]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=136411#p136411" />
			<content type="html"><![CDATA[<p><strong>teadrinker</strong>. так... Вот в массиве номера расписания и время их начала. А можно как-то сделать &quot;защиту&quot; от выдачи расписания которое уже &quot;началось&quot;?</p><div class="codebox"><pre><code>routes := {&quot;00:00:00&quot;: &quot;101&quot;, &quot;01:00:00&quot;: &quot;103&quot;, &quot;02:00:00&quot;: &quot;105&quot;, &quot;03:00:00&quot;: &quot;107&quot;, &quot;04:00:00&quot;: &quot;109&quot;, &quot;05:00:00&quot;: &quot;111&quot;, &quot;06:00:00&quot;: &quot;113&quot;, &quot;07:00:00&quot;: &quot;115&quot;, &quot;07:20:00&quot;: &quot;117&quot;, &quot;07:40:00&quot;: &quot;119&quot;, &quot;08:00:00&quot;: &quot;121&quot;, &quot;08:20:00&quot;: &quot;123&quot;, &quot;08:40:00&quot;: &quot;125&quot;, &quot;09:00:00&quot;: &quot;127&quot;, &quot;09:20:00&quot;: &quot;129&quot;, &quot;09:40:00&quot;: &quot;131&quot;, &quot;10:00:00&quot;: &quot;133&quot;, &quot;10:20:00&quot;: &quot;135&quot;, &quot;10:40:00&quot;: &quot;137&quot;, &quot;11:00:00&quot;: &quot;139&quot;, &quot;11:20:00&quot;: &quot;141&quot;, &quot;11:40:00&quot;: &quot;143&quot;, &quot;12:00:00&quot;: &quot;001&quot;, &quot;12:20:00&quot;: &quot;003&quot;, &quot;12:40:00&quot;: &quot;005&quot;, &quot;13:00:00&quot;: &quot;007&quot;, &quot;13:20:00&quot;: &quot;009&quot;, &quot;13:40:00&quot;: &quot;011&quot;, &quot;14:00:00&quot;: &quot;013&quot;, &quot;14:20:00&quot;: &quot;015&quot;, &quot;14:40:00&quot;: &quot;017&quot;, &quot;15:00:00&quot;: &quot;019&quot;, &quot;15:20:00&quot;: &quot;021&quot;, &quot;15:40:00&quot;: &quot;023&quot;, &quot;16:00:00&quot;: &quot;025&quot;, &quot;16:20:00&quot;: &quot;027&quot;, &quot;16:40:00&quot;: &quot;029&quot;, &quot;17:00:00&quot;: &quot;031&quot;, &quot;17:20:00&quot;: &quot;033&quot;, &quot;17:40:00&quot;: &quot;035&quot;, &quot;18:00:00&quot;: &quot;037&quot;, &quot;18:20:00&quot;: &quot;039&quot;, &quot;18:40:00&quot;: &quot;041&quot;, &quot;19:00:00&quot;: &quot;043&quot;, &quot;19:20:00&quot;: &quot;045&quot;, &quot;19:40:00&quot;: &quot;047&quot;, &quot;20:00:00&quot;: &quot;145&quot;, &quot;20:20:00&quot;: &quot;147&quot;, &quot;20:40:00&quot;: &quot;149&quot;, &quot;21:00:00&quot;: &quot;151&quot;, &quot;21:20:00&quot;: &quot;153&quot;, &quot;21:40:00&quot;: &quot;155&quot;, &quot;22:00:00&quot;: &quot;157&quot;, &quot;23:00:00&quot;: &quot;159&quot;, &quot;00:30:00&quot;: &quot;102&quot;, &quot;01:30:00&quot;: &quot;104&quot;, &quot;02:30:00&quot;: &quot;106&quot;, &quot;03:30:00&quot;: &quot;108&quot;, &quot;04:30:00&quot;: &quot;110&quot;, &quot;05:30:00&quot;: &quot;112&quot;, &quot;06:30:00&quot;: &quot;114&quot;, &quot;07:10:00&quot;: &quot;116&quot;, &quot;07:30:00&quot;: &quot;118&quot;, &quot;07:50:00&quot;: &quot;120&quot;, &quot;08:10:00&quot;: &quot;122&quot;, &quot;08:30:00&quot;: &quot;124&quot;, &quot;08:50:00&quot;: &quot;126&quot;, &quot;09:10:00&quot;: &quot;128&quot;, &quot;09:30:00&quot;: &quot;130&quot;, &quot;09:50:00&quot;: &quot;132&quot;, &quot;10:10:00&quot;: &quot;134&quot;, &quot;10:30:00&quot;: &quot;136&quot;, &quot;10:50:00&quot;: &quot;138&quot;, &quot;11:10:00&quot;: &quot;140&quot;, &quot;11:30:00&quot;: &quot;142&quot;, &quot;11:50:00&quot;: &quot;144&quot;, &quot;12:10:00&quot;: &quot;002&quot;, &quot;12:30:00&quot;: &quot;004&quot;, &quot;12:50:00&quot;: &quot;006&quot;, &quot;13:10:00&quot;: &quot;008&quot;, &quot;13:30:00&quot;: &quot;010&quot;, &quot;13:50:00&quot;: &quot;012&quot;, &quot;14:10:00&quot;: &quot;014&quot;, &quot;14:30:00&quot;: &quot;016&quot;, &quot;14:50:00&quot;: &quot;018&quot;, &quot;15:10:00&quot;: &quot;020&quot;, &quot;15:30:00&quot;: &quot;022&quot;, &quot;15:50:00&quot;: &quot;024&quot;, &quot;16:10:00&quot;: &quot;026&quot;, &quot;16:30:00&quot;: &quot;028&quot;, &quot;16:50:00&quot;: &quot;030&quot;, &quot;17:10:00&quot;: &quot;032&quot;, &quot;17:30:00&quot;: &quot;034&quot;, &quot;17:50:00&quot;: &quot;036&quot;, &quot;18:10:00&quot;: &quot;038&quot;, &quot;18:30:00&quot;: &quot;040&quot;, &quot;18:50:00&quot;: &quot;042&quot;, &quot;19:10:00&quot;: &quot;044&quot;, &quot;19:30:00&quot;: &quot;046&quot;, &quot;19:50:00&quot;: &quot;048&quot;, &quot;20:10:00&quot;: &quot;146&quot;, &quot;20:30:00&quot;: &quot;148&quot;, &quot;20:50:00&quot;: &quot;150&quot;, &quot;21:10:00&quot;: &quot;152&quot;, &quot;21:30:00&quot;: &quot;154&quot;, &quot;21:50:00&quot;: &quot;156&quot;, &quot;22:30:00&quot;: &quot;158&quot;, &quot;23:30:00&quot;: &quot;160&quot;}
FormatTime, routetime,, HHmmss
routetime := &quot;20000101&quot; . routetime
prevDiff := 0xFFFFFFFF
for k, v in routes {
   if SubStr(routetime, 9, 2) = &quot;23&quot; &amp;&amp; k = &quot;00:00:00&quot;
      k := &quot;23:59:59&quot;
   time := &quot;20000101&quot; . StrReplace(k, &quot;:&quot;)
   diff := routetime
   diff -= time, s
   if ( Abs(diff) &lt; prevDiff )
      route := v, prevDiff := Abs(diff)
}</code></pre></div><p>Т.е по факту сделать так, что-бы в 1:02 выдавалось расписание не на 1:00, а на 1:30.</p><p>Заранее спасибо!</p>]]></content>
			<author>
				<name><![CDATA[Dozilius]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=40446</uri>
			</author>
			<updated>2019-10-19T22:10:10Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=136411#p136411</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Приближение значения 1 переменной к другой при сравнении.]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=136408#p136408" />
			<content type="html"><![CDATA[<p>Или можно дополнительный ключ &quot;23:59:59&quot; вставить с тем же значением, что и &quot;00:00:00&quot;.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2019-10-19T20:34:13Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=136408#p136408</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Приближение значения 1 переменной к другой при сравнении.]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=136407#p136407" />
			<content type="html"><![CDATA[<p><strong>teadrinker</strong>, огромнейшее спасибо!</p>]]></content>
			<author>
				<name><![CDATA[Dozilius]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=40446</uri>
			</author>
			<updated>2019-10-19T20:29:35Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=136407#p136407</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Приближение значения 1 переменной к другой при сравнении.]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=136406#p136406" />
			<content type="html"><![CDATA[<p>Тогда такой костыль можно вставить:<br /></p><div class="codebox"><pre><code>route := {&quot;20:00:00&quot;: &quot;001&quot;, &quot;20:30:00&quot;: &quot;002&quot;, &quot;21:00:00&quot;: &quot;003&quot;, &quot;22:00:00&quot;: &quot;004&quot;, &quot;23:00:00&quot;: &quot;005&quot;, &quot;00:00:00&quot;: &quot;006&quot;}
Var := &quot;234000&quot;
Var := &quot;20000101&quot; . Var
prevDiff := 0xFFFFFFFF
for k, v in route {
   if SubStr(Var, 9, 2) = &quot;23&quot; &amp;&amp; k = &quot;00:00:00&quot;
      k := &quot;23:59:59&quot;
   time := &quot;20000101&quot; . StrReplace(k, &quot;:&quot;)
   diff := Var
   diff -= time, s
   if ( Abs(diff) &lt; prevDiff )
      min := v, prevDiff := Abs(diff)
}
MsgBox, % min</code></pre></div>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2019-10-19T20:14:23Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=136406#p136406</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Приближение значения 1 переменной к другой при сравнении.]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=136405#p136405" />
			<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>2019-10-19T20:02:59Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=136405#p136405</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Приближение значения 1 переменной к другой при сравнении.]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=136404#p136404" />
			<content type="html"><![CDATA[<p><strong>teadrinker</strong>, огромное спасибо, работает, НО, как быть, если 23:45, например. Приближает к 23:00, а не 00:00</p>]]></content>
			<author>
				<name><![CDATA[Dozilius]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=40446</uri>
			</author>
			<updated>2019-10-19T20:02:26Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=136404#p136404</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Приближение значения 1 переменной к другой при сравнении.]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=136403#p136403" />
			<content type="html"><![CDATA[<p>Попробуйте так:<br /></p><div class="codebox"><pre><code>route := {&quot;20:00:00&quot;: &quot;001&quot;, &quot;20:30:00&quot;: &quot;002&quot;, &quot;21:00:00&quot;: &quot;003&quot;}
FormatTime, Var,, HHmmss
Var := &quot;20000101&quot; . Var
prevDiff := 0xFFFFFFFF
for k, v in route {
   time := &quot;20000101&quot; . StrReplace(k, &quot;:&quot;)
   diff := Var
   diff -= time, s
   if ( Abs(diff) &lt; prevDiff )
      min := v, prevDiff := Abs(diff)
}
MsgBox, % min</code></pre></div>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2019-10-19T19:36:24Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=136403#p136403</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Приближение значения 1 переменной к другой при сравнении.]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=136400#p136400" />
			<content type="html"><![CDATA[<p><strong>teadrinker</strong>, я просто сократил массив, на самом деле там от 00:00 до 23:00 время стоит, не буду я же сюда всё копировать.</p>]]></content>
			<author>
				<name><![CDATA[Dozilius]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=40446</uri>
			</author>
			<updated>2019-10-19T18:14:26Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=136400#p136400</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Приближение значения 1 переменной к другой при сравнении.]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=136396#p136396" />
			<content type="html"><![CDATA[<p>А если 09:00:00, тогда что должно быть?</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2019-10-19T17:39:30Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=136396#p136396</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK: Приближение значения 1 переменной к другой при сравнении.]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=136391#p136391" />
			<content type="html"><![CDATA[<p>У меня есть массив:<br /></p><div class="codebox"><pre><code>route := {&quot;20:00:00&quot;: &quot;001&quot;, &quot;20:30:00&quot;: &quot;002&quot;, &quot;21:00:00&quot;: &quot;003&quot;}</code></pre></div><p>Затем идёт сравнение с массивом:<br /></p><div class="codebox"><pre><code>
FormatTime, Var,, HH:mm:ss
if route.HasKey(Var)
	Var2 := route[Var]
</code></pre></div><p>Теперь самое главное:<br />Мне нужно что-бы если например Var = 20:02:00, она определялась как 001, а скажем 20:20:00 как 002.<br />Т.е как бы приближалась к одному из значений.</p><p>p.s: я чайник, объясните поподробнее. Спасибо.</p>]]></content>
			<author>
				<name><![CDATA[Dozilius]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=40446</uri>
			</author>
			<updated>2019-10-19T16:42:31Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=136391#p136391</id>
		</entry>
</feed>
