<?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=8332&amp;type=atom" />
	<updated>2019-05-15T07:34:10Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=8332</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK:Замена символов в строке]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=134327#p134327" />
			<content type="html"><![CDATA[<p>Касательно причины переносов строк — <a href="http://forum.script-coding.com/viewtopic.php?id=10138">http://forum.script-coding.com/viewtopic.php?id=10138</a>.</p><p>По поводу исправления текста, набранного в неверной раскладке, тут много сочинений и несколько тем на форуме. Как и всякий порядочный форумчанин я пользуюсь собственным велосипедом — <a href="http://forum.script-coding.com/viewtopic.php?pid=113978#p113978">http://forum.script-coding.com/viewtopi … 78#p113978</a>.</p><div class="quotebox"><cite>a154802 пишет:</cite><blockquote><p>строr</p></blockquote></div><p><img src="//forum.script-coding.com/img/smilies/lol.png" width="15" height="15" /></p>]]></content>
			<author>
				<name><![CDATA[stealzy]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=31937</uri>
			</author>
			<updated>2019-05-15T07:34:10Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=134327#p134327</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK:Замена символов в строке]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=134324#p134324" />
			<content type="html"><![CDATA[<p><strong>a154802</strong>, мне непонятен такой метод, свою проблему (превращение кириллицы в текст, который можно передать в url) я решал вот так:<br /></p><div class="codebox"><pre><code>translit(repstr)
{
	StringReplace, repstr, repstr, а , [[a]] , All
	StringReplace, repstr, repstr, б , [[b]] , All
	StringReplace, repstr, repstr, в , [[v]] , All
	StringReplace, repstr, repstr, г , [[g]] , All
	StringReplace, repstr, repstr, д , [[d]] , All
	StringReplace, repstr, repstr, е , [[e]] , All
	StringReplace, repstr, repstr, ё , [[yo]] , All
	StringReplace, repstr, repstr, ж , [[zh]] , All
	StringReplace, repstr, repstr, з , [[z]] , All
	StringReplace, repstr, repstr, и , [[i]] , All
	StringReplace, repstr, repstr, й , [[j]] , All
	StringReplace, repstr, repstr, к , [[k]] , All
	StringReplace, repstr, repstr, л , [[l]] , All
	StringReplace, repstr, repstr, м , [[m]] , All
	StringReplace, repstr, repstr, н , [[n]] , All
	StringReplace, repstr, repstr, о , [[o]] , All
	StringReplace, repstr, repstr, п , [[p]] , All
	StringReplace, repstr, repstr, р , [[r]] , All
	StringReplace, repstr, repstr, с , [[s]] , All
	StringReplace, repstr, repstr, т , [[t]] , All
	StringReplace, repstr, repstr, у , [[u]] , All
	StringReplace, repstr, repstr, ф , [[f]] , All
	StringReplace, repstr, repstr, х , [[x]] , All
	StringReplace, repstr, repstr, ц , [[cz]] , All
	StringReplace, repstr, repstr, ч , [[ch]] , All
	StringReplace, repstr, repstr, ш , [[sh]] , All
	StringReplace, repstr, repstr, щ , [[shh]] , All
	StringReplace, repstr, repstr, ъ , [[````]] , All
	StringReplace, repstr, repstr, ы , [[y&#039;]] , All
	StringReplace, repstr, repstr, ь , [[``]] , All
	StringReplace, repstr, repstr, э , [[e``]] , All
	StringReplace, repstr, repstr, ю , [[yu]] , All
	StringReplace, repstr, repstr, я , [[ya]] , All

	StringReplace, repstr, repstr, А , [[A]] , All
	StringReplace, repstr, repstr, Б , [[b]] , All
	StringReplace, repstr, repstr, В , [[V]] , All
	StringReplace, repstr, repstr, Г , [[G]] , All
	StringReplace, repstr, repstr, Д , [[D]] , All
	StringReplace, repstr, repstr, Е , [[E]] , All
	StringReplace, repstr, repstr, Ё , [[YO]] , All
	StringReplace, repstr, repstr, Ж , [[ZH]] , All
	StringReplace, repstr, repstr, З , [[Z]] , All
	StringReplace, repstr, repstr, И , [[i]] , All
	StringReplace, repstr, repstr, Й , [[J]] , All
	StringReplace, repstr, repstr, К , [[K]] , All
	StringReplace, repstr, repstr, Л , [[L]] , All
	StringReplace, repstr, repstr, М , [[M]] , All
	StringReplace, repstr, repstr, Н , [[N]] , All
	StringReplace, repstr, repstr, О , [[O]] , All
	StringReplace, repstr, repstr, П , [[P]] , All
	StringReplace, repstr, repstr, Р , [[R]] , All
	StringReplace, repstr, repstr, С , [[S]] , All
	StringReplace, repstr, repstr, Т , [[T]] , All
	StringReplace, repstr, repstr, У , [[u]] , All
	StringReplace, repstr, repstr, Ф , [[F]] , All
	StringReplace, repstr, repstr, Х , [[X]] , All
	StringReplace, repstr, repstr, Ц , [[CZ]] , All
	StringReplace, repstr, repstr, Ч , [[CH]] , All
	StringReplace, repstr, repstr, Ш , [[SH]] , All
	StringReplace, repstr, repstr, Щ , [[SHH]] , All
	StringReplace, repstr, repstr, Ъ , [[````]] , All
	StringReplace, repstr, repstr, Ы , [[Y&#039;]] , All
	StringReplace, repstr, repstr, Ь , [[``]] , All
	StringReplace, repstr, repstr, Э , [[E``]] , All
	StringReplace, repstr, repstr, Ю , [[YU]] , All
	StringReplace, repstr, repstr, Я , [[YA]] , All
	
	return repstr
}</code></pre></div><p>Работает шикарно.</p>]]></content>
			<author>
				<name><![CDATA[belyankin12]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=34408</uri>
			</author>
			<updated>2019-05-15T06:06:27Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=134324#p134324</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK:Замена символов в строке]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=134323#p134323" />
			<content type="html"><![CDATA[<p>Добрый день, начинаю осваивать программмирование в AHK, по этому еще не могу разобраться в некоторый тонкостях. <br />Использовал этот пример как наиболее понятный для замены текста набраного в другой раскладке,</p><div class="codebox"><pre><code>
	string1 := &quot;qwertyuiop[]asdfghjkl;&#039;zxcvbnm,./&quot;
	string2 := &quot;йцукенгшщзхъфывапролджэячсмитьбю.&quot;

	If Clip1 contains q,w,e,r,t,y,u,i,o,p,a,s,d,f,g,h,j,k,l,z,x,c,v,b,n,m
		{
		;MsgBox, The string was found.
		TrayTip, CapsLockV5, В русский, 1, 16
		loop Parse, string1
		StringReplace Clip1, Clip1, % A_LoopField, % SubStr(string2, A_Index, 1), All		
		}
	Else
		{
		;MsgBox, The string was not found.
		TrayTip, CapsLockV5, В английский, 1, 16
		loop Parse, string2
		StringReplace Clip1, Clip1, % A_LoopField, % SubStr(string1, A_Index, 1), All			
		}
Send %Clip1%
</code></pre></div><p>модифицировал пример под свои нужды, пока сделал автоматическое определение раскладки и перевода, в последующем думаю все таки остановлюсь на принудительном выборе. <br />Обнаружил у этого примера одну особенность/баг/фичу, если менять раскладку у примера с разрывом строк и переводом каретки, то вставляется 2 перевода строк и каретки.<br />Думал проблема в отсутствии указателя разделения строr в функции &quot;loop Parse, string1&quot;, использовал &quot;loop Parse, string1, `r, `n&quot;, проблема осталась. Попробовал удалить 2ные разделители принудительно &quot;StringReplace, Clip1, Clip1, `r`n`r`n, `r`n, All&quot;, не помогло.<br />Как запустить дебаггер не знаю(( по этому не могу понять откуда такой эффект.</p>]]></content>
			<author>
				<name><![CDATA[a154802]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26538</uri>
			</author>
			<updated>2019-05-15T05:37:20Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=134323#p134323</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK:Замена символов в строке]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=72458#p72458" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>creature.ws пишет:</cite><blockquote><p>В альфа версии autohotkey 2 отсутствие : уже считается ошибкой.</p></blockquote></div><p>Усё ясно. Спасибо за разъяснения.</p>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2013-05-26T14:46:38Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=72458#p72458</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK:Замена символов в строке]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=72457#p72457" />
			<content type="html"><![CDATA[<div class="quotebox"><blockquote><p>Я и не хотел использовать тернарный оператор</p></blockquote></div><p>Но вы же его используете, вдобавок не указав третий операнд.<br /></p><div class="codebox"><pre><code>Так и вопрос, почему это ошибка?</code></pre></div><p>Потому, что нет оператора <strong>?</strong>, есть оператор <strong>? :</strong><br />В альфа версии autohotkey 2 отсутствие <strong>:</strong> <em>уже</em> считается ошибкой.</p>]]></content>
			<author>
				<name><![CDATA[creature.ws]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26105</uri>
			</author>
			<updated>2013-05-26T14:42:35Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=72457#p72457</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK:Замена символов в строке]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=72456#p72456" />
			<content type="html"><![CDATA[<div class="quotebox"><blockquote><p>предполагаю, что предпосылка к этому — желание сократить код, написать его в одну строку</p></blockquote></div><p>Нет. Я же ответил:</p><div class="quotebox"><blockquote><p>Я и не хотел использовать тернарный оператор во избежании вызова лишней операции присваивания переменной.</p></blockquote></div><div class="quotebox"><blockquote><p>предложил краткий вариант записи с эквивалентной функциональностью, но не содержащий ошибок.</p></blockquote></div><p>Так и вопрос, почему это ошибка? Где упоминание про &quot;&amp;&amp;&quot;? Если использовать тернарное выражение, то в нём условие можно не заключать в скобки. Без &quot;или&quot;, условие в скобках обязательно. И дело в том что это я выявил случайно. То есть я в справке не видел примера записи что &quot;если&quot; это, тогда &quot;то&quot; - в одно строку.<br />Потому не пойму где указано что правильно по другому. Но и не нашёл где пишется так, как я пишу <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /><br />Или вы имеете в виду что это баг, который могут поправить, и код станет не рабочим? (вопрос риторический)</p><p>Вообщем суть я уловил. Так писать неправильно.</p><p>ТС. Поправьте код на:<br /></p><div class="codebox"><pre><code>loop Parse, text 
    res .= (p := InStr(string1, A_LoopField, 1)) ?  SubStr(string2, p, 1) : &quot;&quot;
MsgBox  % res</code></pre></div>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2013-05-26T14:36:59Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=72456#p72456</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK:Замена символов в строке]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=72455#p72455" />
			<content type="html"><![CDATA[<p>Кажется, этот диалог никогда не закончится.<br /></p><div class="quotebox"><blockquote><p>Наверное вы имели ввиду:</p></blockquote></div><p>Да какая разница.<br /></p><div class="quotebox"><blockquote><p>Можно пруфлинк на рекомндуемое использование &quot;&amp;&amp;&quot;</p></blockquote></div><p>В коде сообщения #16 вы зачем-то использовали <br /></p><div class="codebox"><pre><code>(p := InStr(string1, A_LoopField, 1)) ? res .= SubStr(string2, p, 1)</code></pre></div><p>предполагая, что предпосылка к этому — желание сократить код, написать его в одну строку, помимо уточнения сути тернарного оператора, в сообщении #18 предложил краткий вариант записи с эквивалентной функциональностью, но не содержащий ошибок.<br /> <br /> <br />В справке вы можете найти статью if (expression), если слова без пруфлинка мало значат — используйте «официальную» конструкцию<br /></p><div class="codebox"><pre><code>if (p := InStr(string1, A_LoopField, 1))
    res .= SubStr(string2, p, 1)</code></pre></div><p>или приведите пруфлинк, по которому рекомендуется использование<br /></p><div class="codebox"><pre><code>(p := InStr(string1, A_LoopField, 1)) ? res .= SubStr(string2, p, 1)</code></pre></div>]]></content>
			<author>
				<name><![CDATA[creature.ws]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26105</uri>
			</author>
			<updated>2013-05-26T14:16:02Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=72455#p72455</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK:Замена символов в строке]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=72453#p72453" />
			<content type="html"><![CDATA[<div class="quotebox"><blockquote><p>допускается конструкция (сondition)? ifBranch без : elseBranch</p></blockquote></div><p>Наверное вы имели ввиду: </p><div class="codebox"><pre><code>(if exp) ? then exp : else exp</code></pre></div><br /><br /><div class="codebox"><pre><code>(if exp) ? then exp</code></pre></div><p>Можно пруфлинк на рекомендуемое использование &quot;&amp;&amp;&quot; в данном случае? Я что-то в справке не найду.</p>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2013-05-26T14:02:00Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=72453#p72453</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK:Замена символов в строке]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=72451#p72451" />
			<content type="html"><![CDATA[<div class="quotebox"><blockquote><p>В чём большой смысл замены</p></blockquote></div><p>Смысле не в замене ? на &amp;&amp;, а в правильном использовании тернарного оператора. То, что в версии 1.1 допускается конструкция <em>(сondition)? ifBranch</em> без <em>: elseBranch</em> — стандартная для Autohotkey синтаксическая поблажка.</p>]]></content>
			<author>
				<name><![CDATA[creature.ws]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26105</uri>
			</author>
			<updated>2013-05-26T07:02:51Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=72451#p72451</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK:Замена символов в строке]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=72448#p72448" />
			<content type="html"><![CDATA[<div class="quotebox"><blockquote><p>Тернарный оператор подразумевает наличие трёх логических фрагментов.</p></blockquote></div><p>Не понимаю я вашей принципиальности по этому вопросу. В чём большой смысл замены &quot;?&quot; на &quot;&amp;&amp;&quot;. Я и не хотел использовать тернарный оператор во избежании вызова лишней операции присваивания переменной. Пусть будет:<br /></p><div class="codebox"><pre><code>     (p := InStr(string1, A_LoopField, 1))  Тогда такой  res .= SubStr(string2, p, 1) </code></pre></div><p>Что это меняет?</p>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2013-05-26T03:11:39Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=72448#p72448</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK:Замена символов в строке]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=72439#p72439" />
			<content type="html"><![CDATA[<div class="codebox"><pre><code>(p := InStr(string1, A_LoopField, 1)) ? res .= SubStr(string2, p, 1)</code></pre></div><p>Тернарный оператор подразумевает наличие трёх логических фрагментов.<br />Уместно его применять если присутствует «или»<br /></p><div class="codebox"><pre><code>res .= (p := InStr(string1, A_LoopField, 1)) ?  SubStr(string2, p, 1) : &quot;другая строка&quot;</code></pre></div><p>Однострочный аналог <em>if (condition) action</em> это <em>(condition) and action</em></p>]]></content>
			<author>
				<name><![CDATA[creature.ws]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26105</uri>
			</author>
			<updated>2013-05-25T19:23:25Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=72439#p72439</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK:Замена символов в строке]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=72433#p72433" />
			<content type="html"><![CDATA[<div class="quotebox"><blockquote><p>serzh82saratov, Заменить ничего неизменив?</p></blockquote></div><p>Иначе переменная была пуста, без пробела. Спасибо за код</p>]]></content>
			<author>
				<name><![CDATA[avens]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24487</uri>
			</author>
			<updated>2013-05-25T17:35:47Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=72433#p72433</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK:Замена символов в строке]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=72431#p72431" />
			<content type="html"><![CDATA[<div class="quotebox"><blockquote><p>пришлось заменить</p></blockquote></div><p>Заменить ничего неизменив?</p><p>А если так:<br /></p><div class="codebox"><pre><code>
text := &quot;aC &amp;&quot;
string1 := &quot;aBC- &amp;&quot;
string2 := &quot;12 567&quot;

loop Parse, text 
    (p := InStr(string1, A_LoopField, 1)) ? res .= SubStr(string2, p, 1)
MsgBox  % res
</code></pre></div><div class="quotebox"><blockquote><p>но все равно 1667, видно что то у меня, буду разбираться.</p></blockquote></div><p>Тот код так и должен работать, там должно быть &quot;1667&quot;.</p>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2013-05-25T17:15:13Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=72431#p72431</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK:Замена символов в строке]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=72430#p72430" />
			<content type="html"><![CDATA[<p>Не надо конделябры <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /></p><p>Я просто еще в своем скрипте думал что пробелы будут учитываться, но пришлось заменить:<br /></p><div class="codebox"><pre><code>destChar = %A_LoopField%
dest = %dest%%destChar%

на

destChar:= A_LoopField
dest:= dest destChar</code></pre></div><p>Скачал последнюю версию, но все равно 1667, видно что то у меня, буду разбираться.</p>]]></content>
			<author>
				<name><![CDATA[avens]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24487</uri>
			</author>
			<updated>2013-05-25T16:55:04Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=72430#p72430</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK:Замена символов в строке]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=72429#p72429" />
			<content type="html"><![CDATA[<p><a href="http://translate.google.com/#auto/ru/capacity">capacity</a><br />Разве речь может идти о мощности в данном контексте? «Синонимы» в таком случае искать нужно. «Вместимость» подходит лучше всего.</p>]]></content>
			<author>
				<name><![CDATA[creature.ws]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26105</uri>
			</author>
			<updated>2013-05-25T16:36:57Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=72429#p72429</id>
		</entry>
</feed>
