<?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=14528</link>
		<atom:link href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=14528&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «AHK: Вырезание строки из файла».]]></description>
		<lastBuildDate>Wed, 30 Jan 2019 23:03:44 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: AHK: Вырезание строки из файла]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=131803#p131803</link>
			<description><![CDATA[<div class="quotebox"><cite>serzh82saratov пишет:</cite><blockquote><p>Но сначала читаю `r`n как `n.</p></blockquote></div><p>Если файл с `n, перезаписываешь с `r`n — некорректно.<br />Лучше так, без всяких фокусов:<br /></p><div class="codebox"><pre><code>countStrings := 3
text =
(
1 строка
2 строка
3 строка
4 строка
5 строка
)

Loop % countStrings {
   text := MoveStringsToEnd(text, 1, moved)
   MsgBox, Запустить: %moved%
}
MsgBox, % &quot;Новый файл:`n`n&quot; text
Return

MoveStringsToEnd(text, count, ByRef moved) {
   RegExMatch(text, &quot;sO)((?:[^`n`r]+(\R)){&quot; . count . &quot;})(.*)&quot;, match)
   Return match[1] != &quot;&quot; ? match[3] . match[2] . (moved := RegExReplace(match[1], &quot;\R$&quot;)) : text
}</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Wed, 30 Jan 2019 23:03:44 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=131803#p131803</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Вырезание строки из файла]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=131802#p131802</link>
			<description><![CDATA[<p>Так поймёте:<br /></p><div class="codebox"><pre><code>countStrings := 3
text =
(
1 строка
2 строка
3 строка
4 строка
5 строка
) 
newText := MoveStringsToEnd(text, countStrings, part)
Loop, Parse, part, `n
	MsgBox, % &quot;Запустить: &quot; A_LoopField
MsgBox, % &quot;Новый файл:`n`n&quot; newText
Return

MoveStringsToEnd(text, count, byref part, d := &quot;`n&quot;) {
	p := InStr(text, d, 0, 1, count)
	Return p ? SubStr(text, p+1) d (part := SubStr(text, 1, p-1)) : text
}</code></pre></div><p><strong>teadrinker</strong><br />Но сначала читаю `r`n как `n.</p>]]></description>
			<author><![CDATA[null@example.com (serzh82saratov)]]></author>
			<pubDate>Wed, 30 Jan 2019 22:42:42 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=131802#p131802</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Вырезание строки из файла]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=131801#p131801</link>
			<description><![CDATA[<p>Так, спасибо вроде разобрался, но только не совсем подходит под мои задачи, нужно чтобы каждую строку по одной выдавал в MsgBox, а не все сразу. Сам файл перезаписывается как надо! Уже большое спасибо за это! Но повторюсь, тут дело в том, что каждая строка это exe по сути, и он будет запускаться с помощью Run, поэтому и нужно чтобы скрипт AHK сместил первые три строки например вниз, но в тоже время и запустил их 01.exe, 02.exe, 03.exe</p>]]></description>
			<author><![CDATA[null@example.com (trezubec)]]></author>
			<pubDate>Wed, 30 Jan 2019 21:55:17 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=131801#p131801</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Вырезание строки из файла]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=131800#p131800</link>
			<description><![CDATA[<p>А, не обратил внимания. Так переписываешь файл с `n на `r`n.</p>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Wed, 30 Jan 2019 21:37:39 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=131800#p131800</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Вырезание строки из файла]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=131799#p131799</link>
			<description><![CDATA[<p>Думаешь FileOpen с &quot;rw`n&quot; не на все случаи?</p>]]></description>
			<author><![CDATA[null@example.com (serzh82saratov)]]></author>
			<pubDate>Wed, 30 Jan 2019 21:28:02 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=131799#p131799</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Вырезание строки из файла]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=131798#p131798</link>
			<description><![CDATA[<p>А откуда ты взял, что d = &quot;`n&quot;?</p>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Wed, 30 Jan 2019 21:22:58 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=131798#p131798</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Вырезание строки из файла]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=131797#p131797</link>
			<description><![CDATA[<p><strong>trezubec</strong><br /></p><div class="codebox"><pre><code>
#SingleInstance Force
#NoEnv
#Persistent

FileName = %A_ScriptFullPath%
File := FileOpen(FileName, &quot;rw`n&quot;)
File.Pos := 0
FileStr := File.Read()   
File.Length := 0
MsgBox % FileStr   
newText := MoveStringsToEnd(FileStr, 10)
MsgBox % newText 
File.Write(newText)
File.Close()
Return

MoveStringsToEnd(text, count, d := &quot;`n&quot;) {
	p := InStr(text, d, 0, 1, count) 
	Return p ? SubStr(text, p+1) d SubStr(text, 1, p-1) : text
}

</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (serzh82saratov)]]></author>
			<pubDate>Wed, 30 Jan 2019 21:11:41 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=131797#p131797</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Вырезание строки из файла]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=131796#p131796</link>
			<description><![CDATA[<p>RegEx наверное тоже не нужен.<br /></p><div class="codebox"><pre><code>countStrings := 4
text =
(
1 строка
2 строка
3 строка
4 строка
5 строка
) 
newText := MoveStringsToEnd(text, countStrings)
MsgBox, % newText
Return

MoveStringsToEnd(text, count, d := &quot;`n&quot;) {
	p := InStr(text, d, 0, 1, count) 
	Return p ? SubStr(text, p+1) d SubStr(text, 1, p-1) : text
}</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (serzh82saratov)]]></author>
			<pubDate>Wed, 30 Jan 2019 21:02:49 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=131796#p131796</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Вырезание строки из файла]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=131795#p131795</link>
			<description><![CDATA[<p><strong>teadrinker</strong><br />countStrings := 1 пробовал.</p>]]></description>
			<author><![CDATA[null@example.com (serzh82saratov)]]></author>
			<pubDate>Wed, 30 Jan 2019 20:57:01 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=131795#p131795</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Вырезание строки из файла]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=131794#p131794</link>
			<description><![CDATA[<p><strong>teadrinker</strong><br />Прошу прощения что я баран )) Но можно ли привести на моем примере с файлом, я не совсем понял куда я должен в скрипт вписать название файла )</p>]]></description>
			<author><![CDATA[null@example.com (trezubec)]]></author>
			<pubDate>Wed, 30 Jan 2019 20:54:53 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=131794#p131794</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Вырезание строки из файла]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=131793#p131793</link>
			<description><![CDATA[<p>Для этого Loop вовсе не нужен.<br /></p><div class="codebox"><pre><code>countStrings := 3
text =
(
1 строка
2 строка
3 строка
4 строка
5 строка
)
newText := MoveStringsToEnd(text, countStrings)
MsgBox, % newText
Return

MoveStringsToEnd(text, count) {
   RegExMatch(text, &quot;O)([^`n`r]+(\R|$)??){&quot; . count . &quot;}&quot;, match)
   Return match ? RegExReplace( SubStr(text, match.Len + StrLen(match[2]) + 1), &quot;\R*$&quot;, match[2] . match[0],, 1 ) : text
}</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Wed, 30 Jan 2019 20:27:40 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=131793#p131793</guid>
		</item>
		<item>
			<title><![CDATA[AHK: Вырезание строки из файла]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=131779#p131779</link>
			<description><![CDATA[<p>Уважаемые гуру, помогите пожалуйста с кодом.<br />Он наверное безобразный, т.к. я частями его собрал с разных тем форумов.</p><p>Вот что получилось</p><div class="codebox"><pre><code>FILE = Список.txt

FileRead, out, %FILE%
loop, parse, out, `n, `r
{
	CNT_STROK:=a_index ; - запись в CNT_STROK количество строк
	If (A_LoopField != &quot;&quot;)
		Num++
}
FileReadLine, line, %FILE%, 1

Loop, read, %FILE%, tempfile.txt
{
   IfNotInString, A_LoopReadLine, %line%, FileAppend, %A_LoopReadLine%`n
}

FileMove, tempfile.txt, %FILE%, 1
}</code></pre></div><p>Список в файле это название профилей браузера, каждая из строк будет потом запускать браузер с нужным профилем, это я постараюсь сам реализовать.</p><p>К вам я за помощью по коду, если не затруднит, подскажите, как переделать код так, чтобы в цикле можно было указать количество строк для вырезания, например Loop, 3, т.е. три строки первые строки вырезаем и смещаем их в тот же файл, но в конец, и после каждого пройденного цикла, выдавал MsgBox с названием вырезанной строки..</p><p>Можно ли переделать данный код под эту задачу? Буду очень признателен за Вашу помощь!</p>]]></description>
			<author><![CDATA[null@example.com (trezubec)]]></author>
			<pubDate>Wed, 30 Jan 2019 13:09:21 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=131779#p131779</guid>
		</item>
	</channel>
</rss>
