<?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=11492&amp;type=atom" />
	<updated>2016-04-12T19:15:25Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=11492</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Преобразование переменной]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=102527#p102527" />
			<content type="html"><![CDATA[<p>На всякий:<br />Если у переменной нет значения, оставить этот текст как есть.<br /></p><div class="codebox"><pre><code>
Text = `%A_Temp`%\`n`%Var`%\
MsgBox % VarReplace(Text)

Text = `%A_Temp`%\`n`%A_ScriptDir`%\
MsgBox % VarReplace(Text)

VarReplace(Text, p := 1) {
	While p := RegExMatch(Text, &quot;%(\w+)%(.*)&quot;, m, p)
		Text := SubStr(Text, 1, p - 1) . (%m1% = &quot;&quot; ? &quot;%&quot; m1 &quot;%&quot; : %m1%) . m2
		, p += StrLen(%m1% = &quot;&quot; ? &quot;%&quot; m1 &quot;%&quot; : %m1%)
	Return Text
}
</code></pre></div>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2016-04-12T19:15:25Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=102527#p102527</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Преобразование переменной]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=102526#p102526" />
			<content type="html"><![CDATA[<p><strong>serzh82saratov</strong>, то что доктор прописал! <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /> Спасибо.</p>]]></content>
			<author>
				<name><![CDATA[exobangs]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=32958</uri>
			</author>
			<updated>2016-04-12T18:52:50Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=102526#p102526</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Преобразование переменной]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=102524#p102524" />
			<content type="html"><![CDATA[<p>Думаю ТС про то, что строка состоит из подстрок вида &quot;%built-in variable%&quot; и текста, и ему надо в конечной строке заменить их на значения.</p><p>Хотя может есть более очевидный способ:<br /></p><div class="codebox"><pre><code>
Text = `%A_Temp`%\`n`%A_ScriptDir`%\`n(`%A_ScriptHWND`%)  
MsgBox % VarReplace(Text)

VarReplace(Text, p := 1) {
	While p := RegExMatch(Text, &quot;%(\w+)%(.*)&quot;, m, p += StrLen(%m1%)) 
		Text := SubStr(Text, 1, p - 1) . %m1% . m2   
	Return Text
}
</code></pre></div>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2016-04-12T17:52:01Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=102524#p102524</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Преобразование переменной]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=102520#p102520" />
			<content type="html"><![CDATA[<p>Правильно так:</p><div class="codebox"><pre><code>ans := Http.responseText</code></pre></div>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2016-04-12T12:44:31Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=102520#p102520</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK: Преобразование переменной]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=102518#p102518" />
			<content type="html"><![CDATA[<p>Возник такой вопрос, к примеру есть код:<br /></p><div class="codebox"><pre><code>
url := тут ссылка на php обработчик.
HTTP := ComObjCreate(&quot;WinHttp.WinHttpRequest.5.1&quot;)
HTTP.Open(&quot;GET&quot;, url, true)
HTTP.SetRequestHeader(&quot;User-Agent&quot;, &quot;Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/7.0)&quot;)
HTTP.Send()
HTTP.WaitForResponse() 
ans = % Http.responseText
</code></pre></div><p>Проблема вот в чем, Http.responseText возвращает путь до файла с иконкой в формате:<br /></p><div class="codebox"><pre><code>
%A_Temp%\test.png
</code></pre></div><p>И возвращает именно буквально, то есть через &quot;:=&quot;, а такое код не воспринимает, ему нужен именно путь.<br />В первый раз, получилось обойти это как сейчас в скрипте:<br /></p><div class="codebox"><pre><code>
ans = % Http.responseText
</code></pre></div><p>Но вот незадача, сработало это и потом я думал что проблема решена, а через пару дней, решил сесть дописывать код, но этот метод уже не работает, выручайте. <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /></p>]]></content>
			<author>
				<name><![CDATA[exobangs]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=32958</uri>
			</author>
			<updated>2016-04-12T12:24:18Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=102518#p102518</id>
		</entry>
</feed>
