<?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=16829&amp;type=atom" />
	<updated>2021-12-17T18:51:10Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=16829</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Поиск строки в списке]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=151236#p151236" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Alex45 пишет:</cite><blockquote><p><strong>Phoenixxx_Czar</strong> Еще возник небольшой вопросик, можно ли узнать количество элементов в массиве listArr?</p></blockquote></div><p>Ну нужно же хоть немного справку открывать <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" />.<br /></p><div class="codebox"><pre><code>list =
(
192.168.1.12
192.168.1.13
192.168.1.14
еще 5000 строк
)

listArr := strSplit(list, &quot;`n&quot;, &quot;`r&quot;)

msgbox, % listArr.maxIndex()</code></pre></div><p>И согласен с комментарием выше, это должно решить проблему с fileRead.</p>]]></content>
			<author>
				<name><![CDATA[Phoenixxx_Czar]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=34426</uri>
			</author>
			<updated>2021-12-17T18:51:10Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=151236#p151236</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Поиск строки в списке]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=151233#p151233" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Phoenixxx_Czar пишет:</cite><blockquote><div class="codebox"><pre><code>listArr := strSplit(list, &quot;`n&quot;)</code></pre></div></blockquote></div><p>Лучше так:<br /></p><div class="codebox"><pre><code>listArr := StrSplit(list, &quot;`n&quot;, &quot;`r&quot;)</code></pre></div>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2021-12-17T10:18:46Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=151233#p151233</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Поиск строки в списке]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=151232#p151232" />
			<content type="html"><![CDATA[<p>И почему то не ищет, если в переменную list добавить строки из файла через FileRead</p>]]></content>
			<author>
				<name><![CDATA[Alex45]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=42224</uri>
			</author>
			<updated>2021-12-17T08:43:39Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=151232#p151232</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Поиск строки в списке]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=151230#p151230" />
			<content type="html"><![CDATA[<p><strong>Phoenixxx_Czar</strong> Еще возник небольшой вопросик, можно ли узнать количество элементов в массиве listArr?</p>]]></content>
			<author>
				<name><![CDATA[Alex45]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=42224</uri>
			</author>
			<updated>2021-12-17T07:46:56Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=151230#p151230</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Поиск строки в списке]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=151229#p151229" />
			<content type="html"><![CDATA[<p><strong>Phoenixxx_Czar</strong> Все работает так как надо, строку находит. Больше суток не мог решить эту задачу (самостоятельно). Спасибо Вам большое!</p>]]></content>
			<author>
				<name><![CDATA[Alex45]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=42224</uri>
			</author>
			<updated>2021-12-17T07:32:13Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=151229#p151229</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Поиск строки в списке]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=151227#p151227" />
			<content type="html"><![CDATA[<p>С помощью &#039;strSplit(list, &quot;`n&quot;)&#039; делаем из строки - массив.<br />С помощью &#039;hasVal(arr, value)&#039; проверяем, есть ли указанное значение (value) в массиве (arr). В нашем случае есть ли в массиве listArr, значение из переменной out1 и out2.</p><div class="codebox"><pre><code>out1 = 192.168.1.1
out2 = 192.168.1.14

list =
(
192.168.1.12
192.168.1.13
192.168.1.14
еще 5000 строк
)

; listArr := strSplit(list, &quot;`n&quot;)
listArr := StrSplit(list, &quot;`n&quot;, &quot;`r&quot;)

msgbox, % out1 (hasVal(listArr, out1) ? &quot;&quot; : &quot; не&quot;) &quot; находится в списке&quot;
msgbox, % out2 (hasVal(listArr, out2) ? &quot;&quot; : &quot; не&quot;) &quot; находится в списке&quot;


hasVal(haystack, needle)
{
    for index, value in haystack
        if (value == needle)
            return index
    return 0
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Phoenixxx_Czar]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=34426</uri>
			</author>
			<updated>2021-12-17T06:52:13Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=151227#p151227</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK: Поиск строки в списке]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=151225#p151225" />
			<content type="html"><![CDATA[<div class="codebox"><pre><code>out = 192.168.1.1

list =
(
192.168.1.12
192.168.1.13
192.168.1.14
еще 5000 строк
)
</code></pre></div><p>Как можно узнать, есть ли уже такая строка (out) в списке (list)?</p>]]></content>
			<author>
				<name><![CDATA[Alex45]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=42224</uri>
			</author>
			<updated>2021-12-17T05:00:19Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=151225#p151225</id>
		</entry>
</feed>
