Sign in to follow this  
Followers 0
bobsyuruncle

Is 4 > 4.00.6221.1000 ?

8 posts in this topic

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?

Share this post


Link to post
Share on other sites



#3 ·  Posted (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 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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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 Value

Success: Following Values:

0 - Both versions equal

1 - Version 1 greater

-1 - Version 2 greater

Failure: @error will be set in the event of a catasrophic error

Remarks

This will try to use a numerical comparison but fall back on a lexicographical comparison.

See @extended for details about which type was performed.


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Yea, didn't know that existed, will come in handy later for me.


Giggity

Share this post


Link to post
Share on other sites

There is alternate version comparison that I wrote here, it may offer more functionality:

#418119

Share this post


Link to post
Share on other sites

#8 ·  Posted (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 by bobsyuruncle

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0