<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK: Loop (Read). Как вернуть пред-пред последнюю строку?]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=9885&amp;type=atom" />
	<updated>2014-08-11T11:15:35Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=9885</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Loop (Read). Как вернуть пред-пред последнюю строку?]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=85829#p85829" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>serzh82saratov пишет:</cite><blockquote><div class="quotebox"><blockquote><p>в справке смотрел, но не там</p></blockquote></div><p>1 <a href="http://www.script-coding.com/AutoHotkeyTranslation.html">Документация по программе AutoHotkey</a><br />2 Ctrl+F в браузере<br />3 пишем <strong>FileRead</strong>&nbsp; в строку поиска</p><p>???</p></blockquote></div><p>Всегда так делаю, у меня даже страница справки в закладках, просто по невнимательности пытался найти ответ на свой вопрос в FileReadLine. <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /></p>]]></content>
			<author>
				<name><![CDATA[Desire]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=30401</uri>
			</author>
			<updated>2014-08-11T11:15:35Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=85829#p85829</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Loop (Read). Как вернуть пред-пред последнюю строку?]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=85828#p85828" />
			<content type="html"><![CDATA[<div class="quotebox"><blockquote><p>в справке смотрел, но не там</p></blockquote></div><p>1 <a href="http://www.script-coding.com/AutoHotkeyTranslation.html">Документация по программе AutoHotkey</a><br />2 Ctrl+F в браузере<br />3 пишем <strong>FileRead</strong>&nbsp; в строку поиска</p><p>???</p>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2014-08-11T10:54:32Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=85828#p85828</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Loop (Read). Как вернуть пред-пред последнюю строку?]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=85827#p85827" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>serzh82saratov пишет:</cite><blockquote><p><a href="http://www.script-coding.com/AutoHotkey/FileRead.html">Русская справка</a> не катит?</p><p>Все эти заморочки для полной универсальности, так как файлы могут быть с тремя вариантами перевода строк - `r`n, `n, `r. Если вариант заранее известен, то это надо указывать в задаче.<br />Поэтому я сказал <strong>Malcev</strong> что StringReplace не совсем то, а также поправил свой вариант.</p></blockquote></div><p>Спасибо, я что-то в справке смотрел, но не там. <img src="//forum.script-coding.com/img/smilies/big_smile.png" width="15" height="15" /></p>]]></content>
			<author>
				<name><![CDATA[Desire]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=30401</uri>
			</author>
			<updated>2014-08-11T10:50:08Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=85827#p85827</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Loop (Read). Как вернуть пред-пред последнюю строку?]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=85826#p85826" />
			<content type="html"><![CDATA[<p><a href="http://www.script-coding.com/AutoHotkey/FileRead.html">Русская справка</a> не катит?</p><p>Все эти заморочки для полной универсальности, так как файлы могут быть с тремя вариантами перевода строк - `r`n, `n, `r. Если вариант заранее известен, то это надо указывать в задаче.<br />Поэтому я сказал <strong>Malcev</strong> что StringReplace не совсем то, а также поправил свой вариант.</p>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2014-08-11T10:37:01Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=85826#p85826</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Loop (Read). Как вернуть пред-пред последнюю строку?]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=85825#p85825" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>serzh82saratov пишет:</cite><blockquote><p>Не то чтобы лучше для конкретной задачи, но если потом надо будет вернуть пред-пред-пред-пред последнюю строку, то с Loop, read будет не очень удобно это делать.</p><p>Поправка в мой вариант с StrSplit:<br /></p><div class="codebox"><pre><code>
b := 2 ; 0 последняя, 1 предпоследняя, и.т.д. 
FileRead, Text, *t %A_ScriptFullPath% 
MsgBox % (a := StrSplit(Text, [&quot;`n&quot;,&quot;`r&quot;]))[a.maxindex()-b]
</code></pre></div></blockquote></div><p>Можно вопрос? Что означает &quot;*t&quot; в этой строке:<br /></p><div class="quotebox"><blockquote><p>FileRead, Text, <span style="color: red"><strong>*t</strong></span> %A_ScriptFullPath%</p></blockquote></div>]]></content>
			<author>
				<name><![CDATA[Desire]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=30401</uri>
			</author>
			<updated>2014-08-11T10:28:48Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=85825#p85825</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Loop (Read). Как вернуть пред-пред последнюю строку?]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=85824#p85824" />
			<content type="html"><![CDATA[<p>Не то чтобы лучше для конкретной задачи, но если потом надо будет вернуть пред-пред-пред-пред последнюю строку, то с Loop, read будет не очень удобно это делать.</p><p>Поправка в мой вариант с StrSplit:<br /></p><div class="codebox"><pre><code>
b := 2 ; 0 последняя, 1 предпоследняя, и.т.д. 
FileRead, Text, *t %A_ScriptFullPath% 
MsgBox % (a := StrSplit(Text, [&quot;`n&quot;,&quot;`r&quot;]))[a.maxindex()-b]
</code></pre></div>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2014-08-11T10:12:37Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=85824#p85824</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Loop (Read). Как вернуть пред-пред последнюю строку?]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=85823#p85823" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>serzh82saratov пишет:</cite><blockquote><p><strong>Desire</strong> <br />Ну и причём тут Loop, read?</p></blockquote></div><p>Да я уже въехал, что ваш вариант лучше. <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /></p>]]></content>
			<author>
				<name><![CDATA[Desire]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=30401</uri>
			</author>
			<updated>2014-08-11T10:09:57Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=85823#p85823</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Loop (Read). Как вернуть пред-пред последнюю строку?]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=85822#p85822" />
			<content type="html"><![CDATA[<p><strong>Desire</strong> <br />Ну и причём тут Loop, read?</p>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2014-08-11T10:08:39Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=85822#p85822</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Loop (Read). Как вернуть пред-пред последнюю строку?]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=85821#p85821" />
			<content type="html"><![CDATA[<p><strong>serzh82saratov</strong>, просто необходимо считывать Log-файл, а он постоянно обновляет и содержит разное кол-во строк.</p>]]></content>
			<author>
				<name><![CDATA[Desire]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=30401</uri>
			</author>
			<updated>2014-08-11T10:05:10Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=85821#p85821</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Loop (Read). Как вернуть пред-пред последнюю строку?]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=85820#p85820" />
			<content type="html"><![CDATA[<p>Так в чём необходимость Loop, read? С FileRead варианты выглядят как то проще:<br /></p><div class="codebox"><pre><code>
b := 2 ; 0 последняя, 1 предпоследняя, и.т.д.
FileRead, Text, % A_ScriptFullPath 
RegExReplace(Text, &quot;m`a)$&quot;, &quot;&quot;, RowCount)
FileReadLine, Line, % A_ScriptFullPath, % RowCount - b
MsgBox % Line
</code></pre></div><p>или<br /></p><div class="codebox"><pre><code>b := 2 ; 0 последняя, 1 предпоследняя, и.т.д.
FileRead, Text, % A_ScriptFullPath 
MsgBox % (a := StrSplit(Text, &quot;`n&quot;, &quot;`r&quot;))[a.maxindex()-b]</code></pre></div>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2014-08-11T10:04:02Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=85820#p85820</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Loop (Read). Как вернуть пред-пред последнюю строку?]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=85818#p85818" />
			<content type="html"><![CDATA[<p>Помог этот код</p><div class="quotebox"><cite>YMP пишет:</cite><blockquote><div class="codebox"><pre><code>
Loop, read, C:\Text.txt
{
    predpred_line := pred_line
    pred_line := last_line
    last_line := A_LoopReadLine
}
</code></pre></div></blockquote></div><p>Только &quot;predpred_line&quot; почему-то всегда оказывалась пустой, а вот &quot;pred_line&quot; выдает нужный результат. <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /></p>]]></content>
			<author>
				<name><![CDATA[Desire]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=30401</uri>
			</author>
			<updated>2014-08-11T09:59:44Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=85818#p85818</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Loop (Read). Как вернуть пред-пред последнюю строку?]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=85817#p85817" />
			<content type="html"><![CDATA[<p><strong>Malcev</strong> <br />Хороший вариант.</p><p>Хотя лучше RegExReplace:<br /></p><div class="codebox"><pre><code>FileRead, Text, %A_ScriptFullPath% 
RegExReplace(Text, &quot;m`a)$&quot;, &quot;&quot;, RowCount)
MsgBox % RowCount</code></pre></div>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2014-08-11T09:52:28Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=85817#p85817</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Loop (Read). Как вернуть пред-пред последнюю строку?]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=85816#p85816" />
			<content type="html"><![CDATA[<p>Можно узнать общее количество строк с помощью StringReplace и UseErrorLevel.<br />И потом прочитать нужную строку с помощью FileReadLine.</p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2014-08-11T09:49:36Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=85816#p85816</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Loop (Read). Как вернуть пред-пред последнюю строку?]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=85815#p85815" />
			<content type="html"><![CDATA[<p>Если без Loop подойдёт, то:<br /></p><div class="codebox"><pre><code>
Text=
(
Строка1

Строка2

Строка3

Нужная строка


)
b := 2 ; 0 последняя, 1 предпоследняя, и.т.д.

MsgBox % (a := StrSplit(Text, &quot;`n&quot;, &quot;`r&quot;))[a.maxindex()-b]
</code></pre></div><p>Конечно тут подразумевается FileRead.</p>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2014-08-11T09:49:00Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=85815#p85815</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Loop (Read). Как вернуть пред-пред последнюю строку?]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=85814#p85814" />
			<content type="html"><![CDATA[<p>Так, наверно.<br /></p><div class="codebox"><pre><code>
Loop, read, C:\Text.txt
{
    predpred_line := pred_line
    pred_line := last_line
    last_line := A_LoopReadLine
}
</code></pre></div>]]></content>
			<author>
				<name><![CDATA[YMP]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=81</uri>
			</author>
			<updated>2014-08-11T09:42:20Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=85814#p85814</id>
		</entry>
</feed>
