</head> <body> <h1>If var [not] in/contains value1,value2,...</h1> <p><a href="../Variables.htm">변수</a>의 내용이 목록에 있는 항목 중 하나에 일치하는지 점검합니다.</p> <pre class="Syntax"> <span class="func">if</span> Var <span class="func">in</span> MatchList <span class="func">if</span> Var <span class="func">not in</span> MatchList <span class="func">if</span> Var <span class="func">contains</span> MatchList <span class="func">if</span> Var <span class="func">not contains</span> MatchList </pre> <h2 id="Parameters">매개변수</h2> <dl> <dt>Var</dt> <dd><p>내용을 점검할 <a href="../Variables.htm">변수</a>의 이름. "in" 연산자는 정확하게 리스트 항목에 부합하기를 요구합니다. "contains" 연산자는 부합이 더 쉽게 일어납니다: <em>Var</em>에 리스트 항목 중 하나가 부문자열로 포함되어 있기만 하면 부합합니다.</p></dd> <dt>MatchList</dt> <dd><p>쉼표로-가른 문자열 리스트. 각 문자열은 <em>Var</em>의 내용과 비교해 부합합니다. <strong>가르는 쉼표 둘레의 스페이스나 탭은 의미가 있습니다</strong>. 부합 문자열의 일부가 된다는 뜻입니다. 예를 들어, <em>MatchList</em>에 <code>ABC , XYZ</code>가 설정되면 <em>Var</em>에는 반드시 ABC와 뒤에 하나의 스페이스가 담기거나 또는 XYZ와 그 앞에 스페이스 하나가 들어 있어야 부합할 수 있습니다.</p> <p>연속적인 두 개의 쉼표는 글자 그대로의 쉼표 하나가 결과입니다. 예를 들어, 다음은 글자 그대로의 쉼표 하나를 string1의 끝에 생산합니다: <code>if Var in string1,,,string2</code>. 비슷하게, 다음 목록에는 항목 하나가 들어 있고 그 안에 글자 그대로의 쉼표가 하나 들어 있습니다: <code>if Var in single,,item</code>. 목록 안에 빈 항목을 포함하려면, 첫 문자를 다음 예제와 같이 쉼표로 만드십시오: <code>if Var in ,string1,string2</code> ("contains" 연산자를 사용할 때, 빈 항목은 언제나 부합합니다. 왜냐하면 빈 문자열은 모든 문자열에 있기 때문입니다).</p> <p><em>MatchList</em> 안의 항목들은 개별적인 매개변수로 취급되지 않기 때문에, 리스트는 변수 안에 완전히 포함될 수 있습니다. 실제로, 그의 길이가 16383 문자를 넘어서면 변수 안에 일부만 포함됩니다. 그 길이가 스크립트 줄의 최대 길이이기 때문입니다. 예를 들어, <em>MatchList</em>는 <code>%List1%,%List2%,%List3%</code>으로 구성될 수 있습니다 -- 여기에서 각각의 부목록은 부합할 방대한 리스트가 포함되어 있습니다.</p> <p>목록에서 16384 문자보다 긴 항목은 초과된 문자들을 새로운 리스트 항목으로 취급합니다. 그래서, 보통 그런 항목은 피하는 것이 가장 좋습니다.</p></dd> </dl> <h2 id="Remarks">논평</h2> <p>언제나 숫자순이 아니라 알파벳 순으로 비교됩니다. 예를 들어, 문자열 "11"는 리스트 항목 "11.0"과 일치하지 않습니다.</p> <p>The "contains" operator is the same as using <a href="InStr.htm">InStr()</a> or <a href="IfInString.htm">If[Not]InString</a> except that multiple search strings are supported (any one of which will cause a match).</p> <p><code><a href="StringCaseSense.htm">StringCaseSense</a> On</code>을 사용하면 대소문자를 구분해 비교할 수 있습니다.</p> <p><em>MatchList</em>가 길면, 여러 개의 짧은 줄로 나눌 수 있습니다. <a href="../Scripts.htm#continuation">계속 섹션</a>을 사용하면 되는데, 이는 가독성과 유지관리성도 향상시켜 줍니다.</p> <p>The operators "in" and "contains" are not supported in <a href="../Variables.htm#Expressions">expressions</a>. Instead, use <a href="IfExpression.htm">If statements</a> such as <code>if (Var ~= "i)\A(Value1|Value2)\z")</code> for "in" or <code>if (Var ~= "i)Value1|Value2")</code> for "contains" to simulate the behavior of these operators.</p> <h2 id="Related">관련 항목</h2> <p><a href="IfBetween.htm">if var between</a>, <a href="IfEqual.htm">IfEqual/Greater/Less</a>, <a href="IfInString.htm">IfInString</a>, <a href="StringCaseSense.htm">StringCaseSense</a>, <a href="Block.htm">블록</a>, <a href="Else.htm">Else</a></p> <h2 id="Examples">예제</h2> <div class="ex" id="ExInString"> <p><a class="ex_number" href="#ExInString"></a> Checks whether <var>var</var> is the file extension exe, bat or com.</p> <pre>if var in exe,bat,com MsgBox 파일 확장자가 실행 유형입니다.</pre> </div> <div class="ex" id="ExInNumber"> <p><a class="ex_number" href="#ExInNumber"></a> Checks whether <var>var</var> is the prime number 1, 2, 3, 5, 7 or 11.</p> <pre>if var in 1,2,3,5,7,11 <em>; 리스트 안에 스페이스를 회피합니다.</em> MsgBox %var%는 소수입니다.</pre> </div> <div class="ex" id="ExContainsNumber"> <p><a class="ex_number" href="#ExContainsNumber"></a> Checks whether <var>var</var> contains the digit 1 or 3.</p> <pre>if var contains 1,3 <em>; 값들을 문자열로 비교한다는 것을 주목하십시오. 숫자로 비교하지 않습니다.</em> MsgBox Var에 1 또는 3이 담겨 있습니다 (Var는 1, 3, 10, 21, 23, 등등이 될 수 있습니다.)</pre> </div> <div class="ex" id="ExVar"> <p><a class="ex_number" href="#ExVar"></a> Checks whether <var>var</var> is one of the items in <var>MyItemList</var>.</p> <pre>if var in %MyItemList% MsgBox %var%는 목록 안에 있습니다.</pre> </div> <div class="ex" id="ExInputBox"> <p><a class="ex_number" href="#ExInputBox"></a> Allows the user to enter a string and checks whether it is the word yes or no.</p> <pre>InputBox, UserInput, Enter YES or NO if UserInput not in yes,no MsgBox 입력이 유효하지 않습니다.</pre> </div> <div class="ex" id="ExWinGetTitle"> <p><a class="ex_number" href="#ExWinGetTitle"></a> Checks whether <var>active_title</var> contains "Address List.txt" or "Customer List.txt" and checks whether it contains "metapad" or "Notepad".</p> <pre>WinGetTitle, active_title, A if active_title contains Address List.txt,Customer List.txt MsgBox 원하는 창 중 하나가 활성화 상태입니다. if active_title not contains metapad,Notepad MsgBox 그러나 메타패드에도 노트패드에도 파일이 열려 있지 않습니다.</pre> </div> </body> </html>