<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Серый форум &mdash; AHK: Как получить строку по адресу?]]></title>
		<link>https://forum.script-coding.com/viewtopic.php?id=6369</link>
		<atom:link href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=6369&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «AHK: Как получить строку по адресу?».]]></description>
		<lastBuildDate>Fri, 28 Oct 2011 04:19:24 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: AHK: Как получить строку по адресу?]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=52977#p52977</link>
			<description><![CDATA[<p>Вопрос задан правильно. Всем спасибо, разобрался. Установил AutoHotkey_L.</p>]]></description>
			<author><![CDATA[null@example.com (D_Pavel)]]></author>
			<pubDate>Fri, 28 Oct 2011 04:19:24 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=52977#p52977</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Как получить строку по адресу?]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=52957#p52957</link>
			<description><![CDATA[<p>Собственно, вопрос, скорее всего задан не совсем правильно. В errorlevel ссылка не на строку (не на переменную), а просто на число определённой длины в байтах, начинающееся с указанного адреса. Если четырёхбайтное, то через разадресацию можно прочитать так:<br /></p><div class="codebox"><pre><code>VarSetCapacity(Var, 4)
NumPut(4294967290, Var)   ; кладём число по указанному адресу

Loop 4
   Number += (*(&amp;Var + A_Index - 1))&lt;&lt;(8*(A_Index - 1))   ; читаем
   
MsgBox, % Number</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Thu, 27 Oct 2011 13:00:30 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=52957#p52957</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Как получить строку по адресу?]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=52956#p52956</link>
			<description><![CDATA[<div class="quotebox"><cite>teadrinker пишет:</cite><blockquote><p>Таким образом получают один байт, расположенный по указанному адресу, в котором будет код первого символа строки.</p></blockquote></div><p>Точно, а я на юникод версии проверял и не заметил закономерности между var и *&amp;var <img src="//forum.script-coding.com/img/smilies/sad.png" width="15" height="15" />. И приведённый пример, естественно, работает только на ascii. Вот универсальный:<br /></p><div class="codebox"><pre><code>string := &quot;это строка&quot; 
While code := A_IsUnicode ? *(&amp;string + A_Index*2-2)+*(&amp;string + A_Index*2-1)*256 : *(&amp;String + A_Index - 1)
   Text .= Chr(code)
MsgBox %Text%</code></pre></div><p>Но выглядит это не очень. Если использовать NumGet, то немного красивее:<br /></p><div class="codebox"><pre><code>string := &quot;это строка&quot; 
While code := A_IsUnicode ? NumGet(string, (A_Index - 1)*2, &quot;ushort&quot;) : NumGet(string, A_Index - 1, &quot;uchar&quot;)
   Text .= Chr(code)
MsgBox %Text%</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (Александр_)]]></author>
			<pubDate>Thu, 27 Oct 2011 13:00:16 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=52956#p52956</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Как получить строку по адресу?]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=52954#p52954</link>
			<description><![CDATA[<div class="quotebox"><cite>D_Pavel пишет:</cite><blockquote><p>Функция возвращает ссылку на строку в errorlevel, но Dereference (*) почему-то не работает:<br /></p><div class="codebox"><pre><code>zzz := *errorlevel
msgbox %zzz%</code></pre></div></blockquote></div><p>Таким образом получают один байт, расположенный по указанному адресу, в котором будет код первого символа строки. Сам символ можно получить через функцию <em>Chr(code)</em>.<br />Работает так:<br /></p><div class="codebox"><pre><code>string = это строка

While code := *(&amp;String + A_Index - 1)   ; пока число расположенное по указанному адресу не будет равно 0
   Text .= Chr(code)                     ; читаем код и сдвигаемся на один байт
   
MsgBox, % Text</code></pre></div><p>Ну, или так (в AHK_L):<br /></p><div class="codebox"><pre><code>string = это строка
MsgBox, % StrGet(&amp;string)</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Thu, 27 Oct 2011 11:51:13 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=52954#p52954</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Как получить строку по адресу?]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=52949#p52949</link>
			<description><![CDATA[<p>В ahk нет строгой типизации, поэтому переменные там хранятся не так как в &quot;традиционных&quot; языках программирования и такие манипуляции с адресами тут не проходят, это видно из следующего примера:<br /></p><div class="codebox"><pre><code>x := 123
y := *&amp;x
msgbox %x%, %y%</code></pre></div><p>По идее мы должны получить сообщение &quot;123, 123&quot;, но получаем другое. Но AHK поддерживает создание &quot;классических&quot; переменных:<br /></p><div class="codebox"><pre><code>VarSetCapacity(x, 4) ; объявляем перенменную x, размером в 4 байта
NumPut(123, x) ; присваиваем ей значение 123
VarSetCapacity(y, 4) ; объявляем перенменную y
NumPut(*&amp;x, y) ; присваиваем ей значение переменной x, по адресу
msgbox % NumGet(x) . &quot;, &quot; . NumGet(y) ;%</code></pre></div><p>В AutoHotkey_L есть так же функции StrGet и StrPut для работы с NULL-terminate строками.</p>]]></description>
			<author><![CDATA[null@example.com (Александр_)]]></author>
			<pubDate>Thu, 27 Oct 2011 10:13:17 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=52949#p52949</guid>
		</item>
		<item>
			<title><![CDATA[AHK: Как получить строку по адресу?]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=52943#p52943</link>
			<description><![CDATA[<p>Функция возвращает ссылку на строку в errorlevel, но Dereference (*) почему-то не работает:<br /></p><div class="codebox"><pre><code>zzz := *errorlevel
msgbox %zzz%</code></pre></div><p>при том numget работает и печатает длинное четырехбайтовое число:<br /></p><div class="codebox"><pre><code>zzz := numget(errorlevel)
msgbox %zzz%</code></pre></div><p>Вопрос в заголовке.</p>]]></description>
			<author><![CDATA[null@example.com (D_Pavel)]]></author>
			<pubDate>Thu, 27 Oct 2011 07:49:47 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=52943#p52943</guid>
		</item>
	</channel>
</rss>
