Example
This custom evaluator checks the actual and expected values for the version of
Tivoli Directory Integrator. It uses the common function, "versionCompare()" on
page 133.
wscript.echo "expect: " & wscript.arguments(0)
wscript.echo "real value: " & wscript.arguments(1)
wscript.echo tdiVersionCompare(wscript.arguments(0), wscript.arguments(1))
function tdiVersionCompare(expect, real)
end function
' Generic function for comparing 2 version strings
'
' Parameters
'
'
'
' ver1 and ver2 are expected to be dot-separated version strings
'(e.g. 1.0.0.4, 2.3, 3.40.26.7800, 2.3.a)Version strings can have any
' number of parts. When comparing versions with different numbers of
' parts, missing parts of the shorter version string will be treated
' as if there was a zero there. If any non-numeric characters are
' included in a version part, those corresponding parts will be compared
' asstrings and not parsed into numeric form
'
' Returns
'
54
Prerequisite Scanner: User's Guide
if len(real) = 0 then
tdiVersionCompare = "FAIL"
exit function
end if
expect = Trim(expect)
real = Trim(real)
Dim expectedVersion
'if (StrComp(Right(expect,1),"+")=0 or StrComp(Right(expect,1),"-")=0) Then
if (Right(expect,1)="+" or Right(expect,1)="-") Then
expectedVersion = Left(expect,len(expect)-1)
else
expectedVersion = expect
end if
Dim cmp
cmp = versionCompare(expectedVersion,real)
if (StrComp(Right(expect,1),"+")=0) Then
' Version must be at least expected value
if (cmp=0 or cmp=-1) Then
tdiVersionCompare = "PASS"
else
tdiVersionCompare = "FAIL"
end if
elseif (StrComp(Right(expect,1),"-")=0) Then
' Version must be less than or equal to expected value
if (cmp=0 or cmp=1) Then
tdiVersionCompare = "PASS"
else
tdiVersionCompare = "FAIL"
end if
elseif cmp=0 then
tdiVersionCompare = "PASS"
else
tdiVersionCompare = "FAIL"
end if
ver1 The first version string
ver2 The second version string
1 version1 > version2
Need help?
Do you have a question about the Prerequisite Scanner and is the answer not in the manual?
Questions and answers