Sign in to follow this  
Followers 0
thepip3r

Wierd Issue... @OSVersion resolves fine -- conditional not?

4 posts in this topic

Func __checkOSVersion()
    Local $os = @OSVersion
    If $os <> "WIN_2003" or $os <> "WIN_2000" or $os <> "WIN_XP" Then
        MsgBox(0, "Operating System Incompatability (" & $os & ")", "Only Windows 2000, XP, and 2003 are supported right now.")
        Exit
    EndIf
EndFunc

@OSVersion reports as "WIN_XP" on my system but since I wrote this function and started using it, its' stopping me from accessing my program again. While I know I can comment it out until I figure out what's wrong, is there something glaringly obvious that's wrong with my logic as to why it IS in fact evaluating to true when it shouldn't be?? TIA.


My Additions:- RunAs AdminDeviant Fun:- Variable Sound Volume

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Think about this line:

If $os <> "WIN_2003" or $os <> "WIN_2000" or $os <> "WIN_XP" Then

It need to be an AND relation:

:D

Edited by Jos

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

i guess i can see how that would work (and it does in the code (ty Jos)) but why wouldn't "or" work??

My screwed up mind??

If $os is not equal to "WIN_2003"

or

$os is not equal to "WIN_2000"

or

$os is not equal to "WIN_XP"

True, True, False

nm... thnx again Jos.


My Additions:- RunAs AdminDeviant Fun:- Variable Sound Volume

Share this post


Link to post
Share on other sites

It is simple when you see it: Whatever OS you have a minimum of 2 out of the 3 conditions is always TRUE thus the If is always true since you use an OR.

It helps when you read the statement out loud.

:D


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

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