#152555 - 2005-11-30 06:54 PM
If statment to detect version not working
|
pfarrelli
Fresh Scripter
Registered: 2005-11-16
Posts: 46
|
After Getfileversion assings a value to my variable $Version and I confirm using at (9,1) $Version which yeilds: 8.0.0.825 The following statment does not hold true:
IF ($Version < 10) do all this funky stuff EndIf
Why?
|
|
Top
|
|
|
|
#152556 - 2005-11-30 07:16 PM
Re: If statment to detect version not working
|
Shawn
Administrator
   
Registered: 1999-08-13
Posts: 8611
|
Thats because your comparing strings, and a string that starts with "8" is greater than a string that starts with "1" (Kixtart will treat your 10 as a string, because your first argument (the version) is a string) ... two options...
The kludgey way - flip the expression around, then kixtart treats the 10 as a number and will try to convert the version to a number, and probably fails somewhere after the first period but it gets the job done ...
Code:
If 10 > $Version ?"do all this funky stuff" Endif
The better way, parse the major version from the string and convert it to numeric (val), then do a pure numeric compare ...
Code:
$MajorVersion = Val(Substr($Version,1,Instr($Version,".")-1))
If $MajorVersion < 10 ? "do all this funky stuff" EndIf
|
|
Top
|
|
|
|
#152557 - 2005-11-30 08:10 PM
Re: If statment to detect version not working
|
pfarrelli
Fresh Scripter
Registered: 2005-11-16
Posts: 46
|
I will give the better way a try over the kloogie way.
That took me a while to decipher!! But I got it! Thanks!
|
|
Top
|
|
|
|
Moderator: Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 525 anonymous users online.
|
|
|