Page 1 of 1 1
Topic Options
#152555 - 2005-11-30 06:54 PM If statment to detect version not working
pfarrelli Offline
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 Offline
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 Offline
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
#152558 - 2005-11-30 08:29 PM Re: If statment to detect version not working
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Right on. I think there are UDF's kicking around that will parse out the major, minor, build, and special build values from a version string. Have a lookie.
Top
#152559 - 2005-11-30 08:37 PM Re: If statment to detect version not working
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11629
Loc: CA
Are you checking an Office version? If so there are a couple of UDFs for that too.
Top
#152560 - 2005-11-30 08:58 PM Re: If statment to detect version not working
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
Double post.
Look here http://www.kixtart.org/ubbthreads/showflat.php?Cat=0&Number=152010&an=0&page=0&vc=1
Same code and some other solutions provided.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#152561 - 2005-11-30 09:23 PM Re: If statment to detect version not working
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11629
Loc: CA
Thanks Mart, yeah just saw it a minute ago.

pfarrelli - please don't cross post. That tends to upset people who are tyring to help you when they have to find/answer in different locations. It also wastes their time reviewing the same question again.

Top
#152562 - 2005-12-01 12:45 AM Re: If statment to detect version not working
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
shawn, why it's better way?
does the same, thus it's not a bit better.
imho.
_________________________
!

download KiXnet

Top
#152563 - 2005-12-01 01:48 AM Re: If statment to detect version not working
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
ok, they're equally good.
Top
#152564 - 2005-12-03 03:53 PM Re: If statment to detect version not working
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
See for example CompareVersions() or MinorVersion() from the UDF Library.
_________________________
There are two types of vessels, submarines and targets.

Top
Page 1 of 1 1


Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 525 anonymous users online.
Newest Members
batdk82, StuTheCoder, M_Moore, BeeEm, min_seow
17885 Registered Users

Generated in 0.129 seconds in which 0.088 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org