<?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=12645&amp;type=atom" />
	<updated>2017-04-29T19:37:54Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=12645</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Переменная в тексте файла]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=115518#p115518" />
			<content type="html"><![CDATA[<p>Объясните мне, чем не устраивает нормальный подход?<br /></p><div class="codebox"><pre><code>a:=&quot;знаки процента и гравис надо экранировать&quot;, b:=&quot;а кавычки &quot;&quot; не надо&quot;
x =
(
Тут разный текст
; %a% ``n 50`% `n
&quot; %b% &quot;&quot;
)
MsgBox % x</code></pre></div><p>Шаблон - есть, переменные - есть,<br />единственное что надо сделать — <br />1) в тексте перед использованием заменить все &quot;`&quot; на &quot;``&quot; и &quot;%&quot; на &quot;`%&quot;.<br />2) перед текстом вставить две строки ( &quot;x =&quot; и &quot;(&quot; ) и после текста одну строку со скобкой.<br />Зачем изголяться с RegEx?</p>]]></content>
			<author>
				<name><![CDATA[stealzy]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=31937</uri>
			</author>
			<updated>2017-04-29T19:37:54Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=115518#p115518</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Переменная в тексте файла]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=115516#p115516" />
			<content type="html"><![CDATA[<p>Исправил.</p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2017-04-29T19:03:40Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=115516#p115516</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Переменная в тексте файла]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=115512#p115512" />
			<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>2017-04-29T18:55:46Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=115512#p115512</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Переменная в тексте файла]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=115511#p115511" />
			<content type="html"><![CDATA[<p><strong>teadrinker</strong>, да, действительно.<br /></p><div class="codebox"><pre><code>var := &quot;общего&quot;
text := &quot;это равно 20%, а то — 50% от %var% количества&quot;
Pos := 1, match := &quot;&quot;
While Pos := RegExMatch(text, &quot;s)(*UCP)%([\w#@$\x80-\x{10ffff}]{1,253})%&quot;, match, Pos)
{
   text := RegexReplace(text, match, %match1%,,1, Pos)
   Pos += StrLen(%match1%)
}
msgbox % text</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2017-04-29T18:47:49Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=115511#p115511</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Переменная в тексте файла]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=115510#p115510" />
			<content type="html"><![CDATA[<p>Про &quot;#IncludeAgain&quot; даже не слышал. Вполне подходит, спасибо.<br />Надеюсь какая-то дополнительная нагрузка на память при большом количестве повторов не появляется?</p>]]></content>
			<author>
				<name><![CDATA[Foma]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=31521</uri>
			</author>
			<updated>2017-04-29T18:42:56Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=115510#p115510</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Переменная в тексте файла]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=115509#p115509" />
			<content type="html"><![CDATA[<p>stealzy, текст-шаблон, в котором есть специальные вставки для замены их значений. Хотелось увидеть какое-то универсальное решение. Но я вижу, что это сложнее чем мне казалось даже для профессионалов.<br />&nbsp; &nbsp;В принципе можно заранее проверять текст и заменять символы, которые могут помешать. И, для решения моей текущей задачи, можно откинуть существование варианта текстов с неизвестными заранее именами переменных.</p>]]></content>
			<author>
				<name><![CDATA[Foma]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=31521</uri>
			</author>
			<updated>2017-04-29T18:40:07Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=115509#p115509</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Переменная в тексте файла]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=115508#p115508" />
			<content type="html"><![CDATA[<p>Что значит &quot;изменить потом&quot;? Вы хотели задать переменные и затем подставить их в текст.<br /></p><div class="codebox"><pre><code>var1 := &quot;aaa&quot;
var2 := &quot;bbb&quot;
#Include 1.txt
MsgBox, %MyText%

var1 := &quot;111&quot;
var2 := &quot;222&quot;
#IncludeAgain 1.txt
MsgBox, %MyText%</code></pre></div><p>Так что ли?</p>]]></content>
			<author>
				<name><![CDATA[ypppu]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=5974</uri>
			</author>
			<updated>2017-04-29T18:34:30Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=115508#p115508</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Переменная в тексте файла]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=115507#p115507" />
			<content type="html"><![CDATA[<p>Спасибо, рассмотрю 6 внимательней.</p><p>С &quot;include&quot; из 5 тоже не всё просто. Изменить значение потом нельзя.<br /></p><div class="codebox"><pre><code>var1 := &quot;aaa&quot;
var2 := &quot;bbb&quot;

#Include 1.txt
MsgBox, %MyText%

var1 := &quot;111&quot;
var2 := &quot;222&quot;

MsgBox, %MyText%</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Foma]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=31521</uri>
			</author>
			<updated>2017-04-29T18:27:49Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=115507#p115507</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Переменная в тексте файла]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=115504#p115504" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Malcev пишет:</cite><blockquote><p>Тогда используйте код из 6 поста</p></blockquote></div><p>Я бы не стал. <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /><br /></p><div class="codebox"><pre><code>var := &quot;b&quot;
text := &quot;это равно 20%, а то — 50% от общего количества&quot;
Pos := 1, match := &quot;&quot;
While Pos := RegExMatch(text, &quot;s)%(.*?)%&quot;, match, Pos)
{
   text := RegexReplace(text, match, %match1%,,1, Pos)
   Pos += StrLen(%match1%)
}
msgbox % text</code></pre></div>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2017-04-29T18:22:29Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=115504#p115504</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Переменная в тексте файла]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=115502#p115502" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Foma пишет:</cite><blockquote><p> А если заранее неизвестны имена всех переменных в тексте?</p></blockquote></div><p>Тогда используйте код из 6 поста.<br />Он заменяет все куски в тексте, обрамленные процентами на их значение.<br /></p><div class="quotebox"><cite>stealzy пишет:</cite><blockquote><p> Если текст, то в нем не должно быть названий переменных.</p></blockquote></div><p>Вы же не знаете откуда этот текст берется.<br />Например, он может браться с веб-страницы, после чего с ним по какой-либо причине нужно проделать эти манипуляции.</p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2017-04-29T17:55:06Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=115502#p115502</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Переменная в тексте файла]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=115501#p115501" />
			<content type="html"><![CDATA[<p><strong>Foma</strong>, вы определитесь уже, у вас текст или код. Если текст, то в нем не должно быть названий переменных.<br />Если код, обращайтесь как с кодом. То что тут сейчас наворотили выглядит жутко.<br /></p><div class="codebox"><pre><code>a := &quot;Начало текста &quot;, b := 2*21, c := &quot;, еще текст.&quot;
d =
(
Много
строк
...
)
MsgBox % s := a b c &quot;`n&quot; d</code></pre></div>]]></content>
			<author>
				<name><![CDATA[stealzy]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=31937</uri>
			</author>
			<updated>2017-04-29T17:34:40Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=115501#p115501</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Переменная в тексте файла]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=115500#p115500" />
			<content type="html"><![CDATA[<p>Сделал.<br />Malcev, интересно получилось. А если заранее неизвестны имена всех переменных в тексте?</p>]]></content>
			<author>
				<name><![CDATA[Foma]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=31521</uri>
			</author>
			<updated>2017-04-29T17:11:25Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=115500#p115500</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Переменная в тексте файла]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=115495#p115495" />
			<content type="html"><![CDATA[<p><span style="color: green"><strong>Foma</strong>, расставьте точки в предложениях:<br /><a href="http://forum.script-coding.com/viewtopic.php?pid=110043#p110043">http://forum.script-coding.com/viewtopi … 43#p110043</a>,<br /><a href="http://forum.script-coding.com/viewtopic.php?pid=110533#p110533">http://forum.script-coding.com/viewtopi … 33#p110533</a>,<br /><a href="http://forum.script-coding.com/viewtopic.php?pid=115490#p115490">http://forum.script-coding.com/viewtopi … 90#p115490</a>.</span></p>]]></content>
			<author>
				<name><![CDATA[ypppu]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=5974</uri>
			</author>
			<updated>2017-04-29T16:18:24Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=115495#p115495</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Переменная в тексте файла]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=115492#p115492" />
			<content type="html"><![CDATA[<p><strong>teadrinker</strong>, если конкретно только переменную var нужно заменить, то проще.<br />Но если уж говорить о простоте, то так ешё проще и быстрее:<br /></p><div class="codebox"><pre><code>var = 777
var1 =
(
111 %var% 222
)
MsgBox, % var1 := StrReplace(var1, &quot;%var%&quot;, var)</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2017-04-29T15:57:35Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=115492#p115492</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Переменная в тексте файла]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=115490#p115490" />
			<content type="html"><![CDATA[<p>Так <br /></p><div class="codebox"><pre><code>:= RegExReplace(var1, &quot;%var%&quot;, var)</code></pre></div><p>можно опустить.</p>]]></content>
			<author>
				<name><![CDATA[Foma]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=31521</uri>
			</author>
			<updated>2017-04-29T15:41:22Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=115490#p115490</id>
		</entry>
</feed>
