? cvs("10.1.183.7","10.1.183.10")
? cvs("10.1.183.10","10.1.183.7")
?
? compareverstring("10.1.183.7","10.1.183.10")
? compareverstring("10.1.183.10","10.1.183.7")
get $
Function CVS($_Version1, $_Version2)
Dim $_X, $_Max
$CVS = 0
$_Version1 = Split($_Version1, '.')
$_Version2 = Split($_Version2, '.')
$_Max=IIf(UBound($_Version1)>UBound($_Version2),UBound($_Version1),UBound($_Version2))
ReDim Preserve $_Version1[$_Max]
ReDim Preserve $_Version2[$_Max]
For $_X = 0 to $_Max
Select
Case CInt($_Version1[$_X]) < CInt($_Version2[$_X])
$CVS=1 Exit 0
Case CInt($_Version1[$_X]) > CInt($_Version2[$_X])
$CVS=-1 Exit 0
EndSelect
Next
Exit 0
EndFunction
Function CompareVerString($_Version1, $_Version2)
Dim $_X, $_Max, $_Val, $_Wt ; Index, Max, Value & Weight vars
Dim $_Err ; error code
Dim $_Vf1, $_Vf2 ; version field counts
$CompareVerString = 0 ; Default to match
$_Version1 = Split($_Version1, '.') ; get version as array of elements
$_Version2 = Split($_Version2, '.')
$_Vf1 = UBound($_Version1) ; elements in version1 array
$_Vf2 = UBound($_Version2) ; elements in version2 array
; insure that both version strings have the same number
; of fields - missing fields are set to 0.
Select ; find highest value
Case $_Vf1 = $_Vf2
$_Max = $_Vf1
Case $_Vf1 < $_Vf2
$_Max = $_Vf2
ReDim Preserve $_Version1[$_Max] ; adjust array and init new values
For $_X = ($_Vf1 + 1) to $_Max $_Version1[$_X] = 0 Next
Case $_Vf1 > $_Vf2
$_Max = $_Vf1
ReDim Preserve $_Version2[$_Max] ; adjust array and init new values
For $_X = ($_Vf2 + 1) to $_Max $_Version2[$_X] = 0 Next
EndSelect
; Compare each element pair in the version strings, starting with the least-significant
; If the element values are equal, they are effictively ignored. If the desired value
; is greater than the installed value, the current Match Value is added to the weight, but
; if the desired value is less than the installed value, the current Match Value is
; subtracted from the weight. The Match Value is increased in binary form as the
; significance of the version values increases. This allows mis-matched string comparisons,
; such as "3.0" and "2.46.24.5", to be processed correctly.
$_Val = 1 ; current match value
$_Wt = 0 ; match weight
For $_X = $_Max to 0 Step -1
Select
Case Val($_Version1[$_X]) < Val($_Version2[$_X])
$_Wt = $_Wt + ($_Val * -1)
Case Val($_Version1[$_X]) > Val($_Version2[$_X])
$_Wt = $_Wt + $_Val
EndSelect
$_Val = $_Val * 2
Next
Select
Case $_Wt > 0
$CompareVerString = -1 ; Version 2 < Version1
Case $_Wt = 0
$CompareVerString = 0 ; Version 2 = Version1
Case $_Wt < 0
$CompareVerString = 1 ; Version 2 > Version1
EndSelect
Exit 0
EndFunction