<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK:  Замена IF на составной тернарный условный оператор]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=9946&amp;type=atom" />
	<updated>2014-09-02T16:55:34Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=9946</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK:  Замена IF на составной тернарный условный оператор]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=86256#p86256" />
			<content type="html"><![CDATA[<p><strong>Irbis,</strong><br /></p><div class="codebox"><pre><code>true := false
;
; много строк кода
;
varR := &quot;true&quot;
varR := %varR%
MsgBox % varR &quot;`n&quot; foo
varR := varR = &quot;True&quot; ? True : varR = &quot;False&quot; ? False : &quot;ERROR&quot;
MsgBox % varR &quot;`n&quot; foo
</code></pre></div><p>Задача была в считывании настроек (True/False/SomthingElse), но ладно, неважно, мой вариант неверный.<br />Есть вероятность, что содержимое &quot;настройки&quot; совпадет с названием переменной, но...</p><p>...</p>]]></content>
			<author>
				<name><![CDATA[Alectric]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26027</uri>
			</author>
			<updated>2014-09-02T16:55:34Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=86256#p86256</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK:  Замена IF на составной тернарный условный оператор]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=86255#p86255" />
			<content type="html"><![CDATA[<p><strong>Alectric</strong>, <br /></p><div class="codebox"><pre><code>foo := 123456
;
; много строк кода
;
varR := &quot;foo&quot;
varR := %varR%
varR := varR = &quot;&quot; ? &quot;ERROR&quot; : varR
MsgBox % varR</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Irbis]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27384</uri>
			</author>
			<updated>2014-09-02T16:48:56Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=86255#p86255</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK:  Замена IF на составной тернарный условный оператор]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=86253#p86253" />
			<content type="html"><![CDATA[<p>Еще можно так:<br /></p><div class="codebox"><pre><code>
varR := &quot;False&quot;
varR := %varR%
MsgBox % varR

varR := &quot;true&quot;
varR := %varR%
MsgBox % varR

varR := &quot;dsgd&quot;
varR := %varR%
MsgBox % varR

varR := &quot;dsgd&quot;
varR := %varR%
varR := varR = &quot;&quot; ? &quot;ERROR&quot; : varR
MsgBox % varR

</code></pre></div><p>При других значениях (кроме 0) возвращает пустую строку - т.е. &quot;False&quot;.</p><p>...</p>]]></content>
			<author>
				<name><![CDATA[Alectric]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26027</uri>
			</author>
			<updated>2014-09-02T15:46:53Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=86253#p86253</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK:  Замена IF на составной тернарный условный оператор]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=86252#p86252" />
			<content type="html"><![CDATA[<p>Спасибо... буду проверять.</p>]]></content>
			<author>
				<name><![CDATA[Indomito]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27285</uri>
			</author>
			<updated>2014-09-02T15:14:43Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=86252#p86252</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK:  Замена IF на составной тернарный условный оператор]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=86251#p86251" />
			<content type="html"><![CDATA[<p>Кратко как-то так:<br /></p><div class="codebox"><pre><code>vSec := &quot;Flags&quot;
varR := 123
(vSec = &quot;Flags&quot;) &amp;&amp; varR := varR = &quot;True&quot; ? True : varR = &quot;False&quot; ? False : &quot;ERROR&quot;
MsgBox % varR</code></pre></div>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2014-09-02T15:04:05Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=86251#p86251</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK:  Замена IF на составной тернарный условный оператор]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=86250#p86250" />
			<content type="html"><![CDATA[<p>По сути ты прав, но тогда надо...</p><p>1. Учитывать имя секции (оно заведомо известно) например <strong>vSec := &quot;Flags&quot;</strong><br />2. Переменной varR присвоить слово ERROR - <strong>varR := &quot;ERROR&quot;</strong></p><p>А это можно как то записать в <em>тернарном условном операторе</em> (многоступенчатые <strong>IF-ELSE</strong> утомляют)? <br />Я просто не знаю тонкостей AHK в данном вопросе.</p>]]></content>
			<author>
				<name><![CDATA[Indomito]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27285</uri>
			</author>
			<updated>2014-09-02T14:52:25Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=86250#p86250</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK:  Замена IF на составной тернарный условный оператор]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=86249#p86249" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Indomito пишет:</cite><blockquote><p>мне нужно было при чтении из ini-файла отработать вариант, когда флаг задаётся не числом, а одним из этих двух ключевых слов</p></blockquote></div><p>Всё равно нужно отрабатывать все варианты, т. к.:<br /></p><div class="codebox"><pre><code>varR := 123
; varR := &quot;False&quot;
varR := varR = &quot;True&quot; ? True : varR := varR = &quot;False&quot; ? False : ;

MsgBox % varR
Return</code></pre></div>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2014-09-02T14:38:15Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=86249#p86249</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK:  Замена IF на составной тернарный условный оператор]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=86248#p86248" />
			<content type="html"><![CDATA[<div class="quotebox"><blockquote><p>Также отсутствует проверка на вариант, что переменная не равна ни тому, ни другому.</p></blockquote></div><p> это происходит ранее, мне нужно было при чтении из ini-файла отработать вариант, когда флаг задаётся не числом, а одним из этих двух ключевых слов, так сказать - <em>&quot;на всякий случай&quot;</em><strong>/</strong><em>&quot;защита от дурака&quot;</em>... хотя можно и проверять вариант не True и не False, но функция просто считывает то что её попросили и не более.</p>]]></content>
			<author>
				<name><![CDATA[Indomito]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27285</uri>
			</author>
			<updated>2014-09-02T14:30:32Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=86248#p86248</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK:  Замена IF на составной тернарный условный оператор]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=86246#p86246" />
			<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>2014-09-02T14:13:14Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=86246#p86246</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK:  Замена IF на составной тернарный условный оператор]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=86245#p86245" />
			<content type="html"><![CDATA[<p>Те ошибка в двойном использовании <strong>varR := varR</strong> Да?</p>]]></content>
			<author>
				<name><![CDATA[Indomito]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27285</uri>
			</author>
			<updated>2014-09-02T14:09:52Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=86245#p86245</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK:  Замена IF на составной тернарный условный оператор]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=86244#p86244" />
			<content type="html"><![CDATA[<p>Правильно так:<br /></p><div class="codebox"><pre><code>varR := &quot;True&quot;
; varR := &quot;False&quot;
varR := varR = &quot;True&quot; ? True : varR = &quot;False&quot; ? False : varR

MsgBox % varR
Return</code></pre></div>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2014-09-02T13:21:18Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=86244#p86244</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK:  Замена IF на составной тернарный условный оператор]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=86242#p86242" />
			<content type="html"><![CDATA[<p>По сути я немного сомневаюсь, вот и решил спросить.</p><p>Было </p><div class="codebox"><pre><code>  if (varR=&quot;False&quot;)
        varR := False
  if (varR=&quot;True&quot;)
        varR := True</code></pre></div><p>Стало </p><div class="codebox"><pre><code>varR := varR = &quot;True&quot; ? True : varR := varR = &quot;False&quot; ? False : ;</code></pre></div><p>Проверил скриптом </p><div class="codebox"><pre><code>varR := &quot;True&quot;
//varR := &quot;False&quot;
varR := varR = &quot;True&quot; ? True : varR := varR = &quot;False&quot; ? False : ;

MsgBox % varR
Return</code></pre></div><p> Честно выдаёт <br />При varR := &quot;True&quot;&nbsp; -&gt; 1<br />При varR := &quot;False&quot; -&gt; 0</p><p>Но я всё же сомневаюсь... такие конструкции на <strong>С++</strong> работают исправно, но я не ожидал, что и на <strong>AHK</strong> они тоже сработают...</p>]]></content>
			<author>
				<name><![CDATA[Indomito]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27285</uri>
			</author>
			<updated>2014-09-02T13:10:40Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=86242#p86242</id>
		</entry>
</feed>
