Compares two version strings.
Result := VerCompare(VersionA, VersionB)
Type: String
The first version string to be compared.
Type: String
The second version string to be compared, optionally prefixed with one of the following operators: <
, <=
, >
, >=
or =
.
Type: Integer (boolean) or Integer
If VersionB begins with an operator symbol, this function returns 1 (true) or 0 (false).
Otherwise, this function returns one of the following to indicate the relationship between VersionA and VersionB:
To check for a specific relationship between the two strings, compare the result to 0. For example:
a_less_than_b := VerCompare(a, b) < 0 a_greater_than_or_equal_to_b := VerCompare(a, b) >= 0
Version strings are compared according to the same rules as #Requires.
This function should correctly compare Semantic Versioning 2.0.0 version strings, but the parameters are not required to be valid SemVer strings.
This function can be used in a sort callback.
Known limitation: Any numeric component greater than 2147483647 (231-1) is considered equal to 2147483647.
Checks the version of AutoHotkey in use.
if VerCompare(A_AhkVersion, "2.0") < 0 MsgBox "This version < 2.0; possibly a pre-release version." else MsgBox "This version is 2.0 or later."
Shows one difference between VerCompare and StrCompare.
MsgBox VerCompare("1.20.0", "1.3") ; Returns 1 MsgBox StrCompare("1.20.0", "1.3") ; Returns -1