bobsyuruncle Posted April 16, 2009 Share Posted April 16, 2009 Ahoy! CODE $regtest = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\SMS\Mobile Client", "ProductVersion") if @error Then $sHTML &= "<li>"&$RedXchk&"ProductVersion Reg entry not found: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\SMS\Mobile Client\ProductVersion. Could be bad install</li>"& @CR else If ($regtest >= 4 ) Then $sHTML &= "<li>"&$Greenchk&"SMS Client Version Appears Current:"&$regtest&"</li>"& @CR Else $sHTML &= "<li>"&$RedXchk&"Could be old SMS client version:"&$regtest&"</li>"& @CR EndIf EndIf So I have this chunk of code that checks product version and reports if it's greater than 4 or less... The problem is "If ($regtest >= 4 ) Then" is never true for some reason. $regtest = 4.00.6221.1000 Any ideas what's going wrong with this? Link to comment Share on other sites More sharing options...
Developers Jos Posted April 16, 2009 Developers Share Posted April 16, 2009 You are not comparing numbers since $regtest is a literal string. Tried _VersionCompare() ? Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
torels Posted April 16, 2009 Share Posted April 16, 2009 (edited) 4.00.6221.1000 is not a number!!you should bring both numbers to a standard length (let's say 11 chypres in this case) and remove all points so you would end up with 40062211000 > 40000000000 <-- This is always true Edit: Jos is faster! Edited April 16, 2009 by torels Some Projects:[list][*]ZIP UDF using no external files[*]iPod Music Transfer [*]iTunes UDF - fully integrate iTunes with au3[*]iTunes info (taskbar player hover)[*]Instant Run - run scripts without saving them before :)[*]Get Tube - YouTube Downloader[*]Lyric Finder 2 - Find Lyrics to any of your song[*]DeskBox - A Desktop Extension Tool[/list]indifference will ruin the world, but in the end... WHO CARES :P---------------http://torels.altervista.org Link to comment Share on other sites More sharing options...
youknowwho4eva Posted April 16, 2009 Share Posted April 16, 2009 4.00.6221.1000 wouldn't be considered a number. I think what you would have to do is break the string into individual components and have for example if $regtest[1] >= 4 then where $regtest[1] would be the first numerical digit of the string. I also believe I've seen that the proper way to use number >= or < is to use the number() function. That you would have to check on. Giggity Link to comment Share on other sites More sharing options...
Developers Jos Posted April 16, 2009 Developers Share Posted April 16, 2009 Fun to see you guys all want to reinvent the wheel here _VersionCompare --------------------------------------------------------------------------------Compares two file versions for equality#Include <Misc.au3>_VersionCompare($sVersion1, $sVersion2) Parameters$sVersion1 IN - The first version $sVersion2 IN - The second version Return ValueSuccess: Following Values: 0 - Both versions equal 1 - Version 1 greater -1 - Version 2 greaterFailure: @error will be set in the event of a catasrophic error RemarksThis will try to use a numerical comparison but fall back on a lexicographical comparison.See @extended for details about which type was performed. SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
youknowwho4eva Posted April 16, 2009 Share Posted April 16, 2009 Yea, didn't know that existed, will come in handy later for me. Giggity Link to comment Share on other sites More sharing options...
weaponx Posted April 16, 2009 Share Posted April 16, 2009 There is alternate version comparison that I wrote here, it may offer more functionality:#418119 Link to comment Share on other sites More sharing options...
bobsyuruncle Posted April 17, 2009 Author Share Posted April 17, 2009 (edited) So many completely usable and awesome answers.Thank you again!This is definately enough to make the function finally work for me FYI for anybody who happens to see this thread, the _VersionCompare() function did not work for some reason... same issue as before where 4.xxx wasn't higher than 4.However the function written by weaponx worked great:#418119 Edited April 22, 2009 by bobsyuruncle Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now