<?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>http://forum.script-coding.com/viewtopic.php?id=13179</link>
		<atom:link href="http://forum.script-coding.com/extern.php?action=feed&amp;tid=13179&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «AHK: Деление строки на подстроки».]]></description>
		<lastBuildDate>Mon, 20 Nov 2017 16:56:31 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: AHK: Деление строки на подстроки]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=121446#p121446</link>
			<description><![CDATA[<p><strong>belyankin12</strong>, спасибо!</p>]]></description>
			<author><![CDATA[null@example.com (Coffi)]]></author>
			<pubDate>Mon, 20 Nov 2017 16:56:31 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=121446#p121446</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Деление строки на подстроки]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=121445#p121445</link>
			<description><![CDATA[<p>Я бы не советовал заносить результат функции с аргументом text в переменную text. Ну а так все верно.</p>]]></description>
			<author><![CDATA[null@example.com (belyankin12)]]></author>
			<pubDate>Mon, 20 Nov 2017 16:52:06 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=121445#p121445</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Деление строки на подстроки]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=121444#p121444</link>
			<description><![CDATA[<p><strong>belyankin12</strong>, так?<br /></p><div class="codebox"><pre><code>text := &quot;«Яндекс» - российская транснациональная компания, владеющая одноимённой системой поиска в Сети, интернет-порталами и службами в нескольких странах. Наиболее заметное положение занимает на рынках России, Турции, Белоруссии и Казахстана.&quot;

Func(text, arg) {
	str := StrSplit(text, A_Space)
	rtext := &quot;&quot;
	ttext := &quot;&quot;
	
	While (str.MaxIndex() != &quot;&quot;) {
		if (strlen(str[1]) = arg) {
			rtext .= &quot;&quot; . str[1] . &quot;`n&quot;
			str.Remove(1)
		} else if (strlen(str[1]) &lt; arg) {
			ttext := str[1]
			str.Remove(1)
			Loop {
				var := strlen(ttext) + strlen(str[1]) + 1
				if (var = arg) {
					rtext .= &quot;&quot; . ttext . &quot; &quot; . str1 . &quot;`n&quot;
					str.Remove(1)
					ttext := &quot;&quot;
					break
				} else if (var &lt; arg) {
					ttext .= &quot; &quot; . str[1] . &quot;&quot;
					str.Remove(1)
					continue
				} else {
					rtext .= &quot;&quot; . ttext . &quot;`n&quot;
					ttext := &quot;&quot;
					break
				}
			}
		} else {
			return, false
		}
	}
	return, %rtext%
}

text := func(text, 30)
str := strsplit(text, &quot;`n&quot;)

Loop, % str.MaxIndex() {
    send % str[A_Index] &quot;`n&quot;
}</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (Coffi)]]></author>
			<pubDate>Mon, 20 Nov 2017 16:20:59 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=121444#p121444</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Деление строки на подстроки]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=121443#p121443</link>
			<description><![CDATA[<p>Ну воспользуйтесь функцией повыше чтобы разделить единую строчку на несколько, а потом воспользуйтесь strsplit по `n в качестве разделителя и в цикле все отправляйте:</p><div class="codebox"><pre><code>
text := &quot;123`n123`n123&quot;
str := strsplit(text, &quot;`n&quot;)

Loop, % str.MaxIndex() {
    send % str[A_Index]
}</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (belyankin12)]]></author>
			<pubDate>Mon, 20 Nov 2017 16:16:57 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=121443#p121443</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Деление строки на подстроки]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=121442#p121442</link>
			<description><![CDATA[<div class="quotebox"><cite>belyankin12 пишет:</cite><blockquote><p>Что значит построчно? Я вижу единую строку. По какому принципу строка должна делиться на несколько?</p></blockquote></div><p>То есть, чтобы скрипт вставлял каждую строку построчно:<br /></p><div class="codebox"><pre><code>Text := &quot;«Яндекс» - российская транснациональная компания, владеющая одноимённой системой поиска в Сети, интернет-порталами и службами в нескольких странах. Наиболее заметное положение занимает на рынках России, Турции, Белоруссии и Казахстана.</code></pre></div><p>То есть он вставляет 1-ую строку через Send, - <strong>«Яндекс» - российская</strong><br />Затем, например ждёт 100 мс. И вставляет след. строку - <strong>транснациональная компания,</strong><br />И так далее:<br /></p><div class="quotebox"><blockquote><p>«Яндекс» - российская<br />транснациональная компания,<br />владеющая одноимённой <br />поиска в Сети,<br />интернет-порталами и службами<br />в нескольких странах. <br />заметное положение занимает <br />рынках России, Турции,<br />Белоруссии и Казахстана.</p></blockquote></div>]]></description>
			<author><![CDATA[null@example.com (Coffi)]]></author>
			<pubDate>Mon, 20 Nov 2017 16:03:40 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=121442#p121442</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Деление строки на подстроки]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=121441#p121441</link>
			<description><![CDATA[<p>Хороший алгоритм. Я не додумался суммировать количество символов в словах, я разделял просто по макс. кол-ву символов. Теперь вышло куда короче и работает даже на коротких текстах:<br /></p><div class="codebox"><pre><code>text := &quot;«Яндекс» - российская транснациональная компания, владеющая одноимённой системой поиска в Сети, интернет-порталами и службами в нескольких странах. Наиболее заметное положение занимает на рынках России, Турции, Белоруссии и Казахстана.&quot;

Func(text, arg) {
	str := StrSplit(text, A_Space)
	rtext := &quot;&quot;
	ttext := &quot;&quot;
	
	While (str.MaxIndex() != &quot;&quot;) {
		if (strlen(str[1]) = arg) {
			rtext .= &quot;&quot; . str[1] . &quot;`n&quot;
			str.Remove(1)
		} else if (strlen(str[1]) &lt; arg) {
			ttext := str[1]
			str.Remove(1)
			Loop {
				var := strlen(ttext) + strlen(str[1]) + 1
				if (var = arg) {
					rtext .= &quot;&quot; . ttext . &quot; &quot; . str1 . &quot;`n&quot;
					str.Remove(1)
					ttext := &quot;&quot;
					break
				} else if (var &lt; arg) {
					ttext .= &quot; &quot; . str[1] . &quot;&quot;
					str.Remove(1)
					continue
				} else {
					rtext .= &quot;&quot; . ttext . &quot;`n&quot;
					ttext := &quot;&quot;
					break
				}
			}
		} else {
			return, false
		}
	}
	return, %rtext%
}

msgbox, % func(text, 30)</code></pre></div><p>Если количество символов от предыдущего до следующего пробела больше максимального количества символов, функция возвращает 0.</p>]]></description>
			<author><![CDATA[null@example.com (belyankin12)]]></author>
			<pubDate>Mon, 20 Nov 2017 15:34:56 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=121441#p121441</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Деление строки на подстроки]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=121438#p121438</link>
			<description><![CDATA[<p>Ну и зачем эти ненадежные костыли?<br />Не проще ли действовать по такому алгоритму - разделять слова по знаку пробела, подсчитывать сколько в сумме букв и если меньше заданной, то присоединять к финальной переменной через пробел, а если больше, то через перенос строки?</p>]]></description>
			<author><![CDATA[null@example.com (Malcev)]]></author>
			<pubDate>Mon, 20 Nov 2017 14:24:37 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=121438#p121438</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Деление строки на подстроки]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=121436#p121436</link>
			<description><![CDATA[<p>Знак копирайта можно поменять на любой другой экзотический. Просто этот знак единственный &quot;экзотический&quot; который я вспомнил и который не нужно было с какого-либо сайта копировать (альт + 0169) - использовался для создания функции.</p>]]></description>
			<author><![CDATA[null@example.com (belyankin12)]]></author>
			<pubDate>Mon, 20 Nov 2017 14:04:04 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=121436#p121436</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Деление строки на подстроки]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=121431#p121431</link>
			<description><![CDATA[<p>Он не то, что необязательный, он вредный.<br />Или по-вашему в тексте знак копирайта встречаться не может?</p>]]></description>
			<author><![CDATA[null@example.com (Malcev)]]></author>
			<pubDate>Mon, 20 Nov 2017 12:06:35 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=121431#p121431</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Деление строки на подстроки]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=121430#p121430</link>
			<description><![CDATA[<p>Мне так проще,&nbsp; я понимаю что он совсем не обязательный,&nbsp; но в msgbox проще увидеть спец. знак в конце строчки,&nbsp; чем пробел.</p>]]></description>
			<author><![CDATA[null@example.com (belyankin12)]]></author>
			<pubDate>Mon, 20 Nov 2017 11:59:02 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=121430#p121430</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Деление строки на подстроки]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=121427#p121427</link>
			<description><![CDATA[<p><strong>belyankin12</strong>, а зачем вы используете StringReplace?</p>]]></description>
			<author><![CDATA[null@example.com (Malcev)]]></author>
			<pubDate>Mon, 20 Nov 2017 10:37:43 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=121427#p121427</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Деление строки на подстроки]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=121425#p121425</link>
			<description><![CDATA[<p>Эта функция недописана мной. При проверке на маленьком тексте &quot;ха ха ха ха ха ха ха&quot; с попыткой добавить максимальное количество символов в строке 2 скрипт зацикливался намертво. Потому работает только с большими объемами текстов и большими аргументами. Сейчас у меня нет времени довести её до ума, потому доведите сами:<br /></p><div class="codebox"><pre><code>text := &quot;«Яндекс» - российская транснациональная компания, владеющая одноимённой системой поиска в Сети, интернет-порталами и службами в нескольких странах. Наиболее заметное положение занимает на рынках России, Турции, Белоруссии и Казахстана.&quot;
Fun(text, arg) {
	Loop %arg% {
		if (A_Index = arg) {
			StringReplace, text, text, %A_Space%, `n
			StringReplace, text, text, @#$$, %A_Space%, All
		} else {
			StringReplace, text, text, %A_Space%, @#$$
		}
	}
	return, % text
}

ffunc(text, arg) {
	
	arr2 := []
	wtext := &quot;&quot;
	rtext := &quot;&quot;
	ttext := &quot;&quot;
	ns := 0
	
	StringReplace, wtext, text, %A_Space%, ©, All
	Loop, parse, wtext,, 
	{
		arr2[A_Index] := A_LoopField
	}
	While (arr2.MaxIndex() != &quot;&quot;) {
		if (arr2[arg] = &quot;©&quot;) {
			Loop %arg% {
				if (A_Index = arg) {
					rtext .= &quot;`n&quot;
					break
				}
				rtext .= arr2[A_Index]
			}
			arr2.Remove(1, arg)
		} else {
			Loop %arg% {
				ttext .= arr2[A_Index]
			}
			
			Loop, parse, ttext,,
			{
				if (A_LoopField = &quot;©&quot;) {
					ns := A_Index
				}
			}
				
			Loop %ns% {
				if (A_Index = ns) {
					rtext .= &quot;`n&quot;
					break
				}
				rtext .= arr2[A_Index]
			}
			ttext := &quot;&quot;
			arr2.Remove(1, ns)
		}
	}
	StringReplace, rtext, rtext, ©, %A_Space%, all
	return, %rtext%
}

msgbox, % ffunc(text, 30)</code></pre></div><p>А может кто и подскажет что-то поумнее, а то у меня набор костылей.</p>]]></description>
			<author><![CDATA[null@example.com (belyankin12)]]></author>
			<pubDate>Mon, 20 Nov 2017 09:27:00 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=121425#p121425</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Деление строки на подстроки]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=121424#p121424</link>
			<description><![CDATA[<p>Что значит построчно? Я вижу единую строку. По какому принципу строка должна делиться на несколько?</p>]]></description>
			<author><![CDATA[null@example.com (belyankin12)]]></author>
			<pubDate>Mon, 20 Nov 2017 08:02:29 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=121424#p121424</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Деление строки на подстроки]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=121420#p121420</link>
			<description><![CDATA[<p><strong>belyankin12</strong>, огромное спасибо за такой вариант, я изучил вашу функцию. Но я не понял, как сделать, чтобы он построчно вставлял данный текст, как здесь:<br /></p><div class="codebox"><pre><code>String := &quot;«Яндекс» — российская транснациональная компания, владеющая одноимённой системой поиска в Сети, интернет-порталами и службами в нескольких странах. Наиболее заметное положение занимает на рынках России, Турции, Белоруссии и Казахстана.&quot;, Start := 1, Length := 30

loop
{
   if ((NewString := SubStr(String, Start, Length)) = &quot;&quot;)
      break
   Send % NewString &quot;{Enter}&quot;
   Start+=Length
}
msgbox done</code></pre></div><p>Подскажите пожалуйста, я не понимаю <img src="//forum.script-coding.com/img/smilies/sad.png" width="15" height="15" />. А также, подскажите, как установить максимальное количество слов в каждую строку. Благодарю.</p>]]></description>
			<author><![CDATA[null@example.com (Coffi)]]></author>
			<pubDate>Mon, 20 Nov 2017 06:41:52 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=121420#p121420</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Деление строки на подстроки]]></title>
			<link>http://forum.script-coding.com/viewtopic.php?pid=121418#p121418</link>
			<description><![CDATA[<p>Возможно очень костыльный вариант, но если я правильно понял вашу цель, то он её сможет достичь:</p><div class="codebox"><pre><code>text := &quot;Устав министерства обязан соблюдать каждый сотрудник&quot;

Fun(text, arg) {
	Loop %arg% {
		if (A_Index = arg) {
			StringReplace, text, text, %A_Space%, `n
			StringReplace, text, text, @#$$, %A_Space%, All
		} else {
			StringReplace, text, text, %A_Space%, @#$$
		}
	}
	return, % text
}

msgbox, % fun(text, 3) ; 3 - номер слова, после которого начинается деление </code></pre></div>]]></description>
			<author><![CDATA[null@example.com (belyankin12)]]></author>
			<pubDate>Mon, 20 Nov 2017 05:46:30 +0000</pubDate>
			<guid>http://forum.script-coding.com/viewtopic.php?pid=121418#p121418</guid>
		</item>
	</channel>
</rss>
