</head> <body> <h1>VerCompare() <span class="ver">[v1.1.36+]</span></h1> <p>Compares two version strings.</p> <pre class="Syntax">Result := <span class="func">VerCompare</span>(VersionA, VersionB)</pre> <h2 id="Parameters">Parâmetros</h2> <dl> <dt>VersionA</dt> <dd> <p>The first version string to be compared.</p> </dd> <dt>VersionB</dt> <dd> <p>The second version string to be compared, optionally prefixed with one of the following operators: <code>&lt;</code>, <code>&lt;=</code>, <code>&gt;</code>, <code>&gt;=</code> or <code>=</code>.</p> </dd> </dl> <h2 id="Return_Value">Return Value</h2> <p>If <em>VersionB</em> begins with an operator symbol, this function returns 1 (true) or 0 (false).</p> <p>Otherwise, this function returns one of the following to indicate the relationship between <em>VersionA</em> and <em>VersionB</em>:</p> <ul> <li>0 if <em>VersionA</em> is equal to <em>VersionB</em></li> <li>a positive integer if <em>VersionA</em> is greater than <em>VersionB</em></li> <li>a negative integer if <em>VersionA</em> is less than <em>VersionB</em></li> </ul> <p>To check for a specific relationship between the two strings, compare the result to 0. Por exemplo:</p> <pre>a_less_than_b := VerCompare(a, b) &lt; 0 a_greater_than_or_equal_to_b := VerCompare(a, b) &gt;= 0</pre> <h2 id="Remarks">Remarks</h2> <p>Version strings are compared according to the same rules as <a href="_Requires.htm#compare">#Requires</a>.</p> <p>This function should correctly compare <a href="https://semver.org/spec/v2.0.0.html">Semantic Versioning 2.0.0</a> version strings, but the parameters are not required to be valid SemVer strings.</p> <p>This function can be used in a <a href="Sort.htm#callback">sort callback</a>.</p> <h2 id="Related">Tópicos relacionados</h2> <p><a href="_Requires.htm">#Requires</a>, <a href="Sort.htm">Sort</a></p> <h2 id="Examples">Exemplos</h2> <div class="ex" id="ExBasic"> <p><a class="ex_number" href="#ExBasic"></a> Checks the version of AutoHotkey in use.</p> <pre> if VerCompare(A_AhkVersion, "&gt;=1.1.36.00") MsgBox This version has VerCompare built-in. else MsgBox This version &lt; 1.1.36.00. </pre> </div> <div class="ex" id="ExPre"> <p><a class="ex_number" href="#ExPre"></a> Demonstrates comparison with pre-release versions.</p> <pre> MsgBox % VerCompare("2.0-a137", "2.0-a136") <em>; Returns 1</em> MsgBox % VerCompare("2.0-a137", "2.0") <em>; Returns -1</em> MsgBox % VerCompare("10.2-beta.3", "10.2.0") <em>; Returns -1</em> </pre> </div> <div class="ex" id="ExPreRange"> <p><a class="ex_number" href="#ExPreRange"></a> Demonstrates a range check.</p> <pre> MsgBox % VerCompare("2.0.1", "&gt;=2.0") &amp;&amp; VerCompare("2.0.1", "&lt;2.1") <em>; Returns 1</em> </pre> </div> </body> </html>