Jump to content

[SOLVED] IF, OR what am i doing wrong here...


Recommended Posts

I want to check a file version but I have 2 different versions i want to check again and this doesnt seem to work right...it is only picking up the first value after the <>

$ms1 = @SystemDir & "\msxml4.dll"
$verxp1 = "4.30.2100.0"
$verxp2 = "4.20.9876.0"

$ver = FileGetVersion($ms1)

If $ver <> $verxp1 OR $verxp2 Then
        $ans = MsgBox(1, "","Additional components are required.  Your Version is:  " & $ver )
    Else
        MsgBox(1, "","We are good to go!")
        Exit
EndIf
Edited by gr1fter
Link to comment
Share on other sites

Try:

If ($ver = $verxp1) OR ($ver = $verxp2) Then
     ; Match
Else
     ; No match
EndIf

Or:

Switch $ver
    Case $verxp1, $verxp2
        ; Match

    Case Else
        ; No match

EndSwitch

:mellow:

Edited by PsaltyDS
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

You have to use $ver again to compare it with 2nd variable!

If $ver <> $verxp1 OR $ver <> $verxp2 Then

$ms1 = @SystemDir & "\msxml4.dll"
$verxp1 = "4.30.2100.0"
$verxp2 = "4.20.9876.0"

$ver = FileGetVersion($ms1)

If $ver <> $verxp1 OR $ver <> $verxp2 Then
    $ans = MsgBox(1, "","Additional components are required. Your Version is: " & $ver )
    Else
    MsgBox(1, "","We are good to go!")
    Exit
EndIf

BR,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

$ms1 = @SystemDir & "\msxml4.dll"
$verxp1 = "4.30.2100.0"
$verxp2 = "4.20.9876.0"


$ver = FileGetVersion($ms1)

If $ver <> $verxp1 OR $ver <> $verxp2 Then
        $ans = MsgBox(1, "","Additional components are required.  Your Version is:  " & $ver )
    Else
        MsgBox(1, "","We are good to go!")
        Exit
EndIf

I tried all your suggestions and did not work :mellow:

My test machine has version 4.20.9876.0 of the file i am checking

So it should go to "We are good to go!" but it doesnt...

If i do this... it works fine...

$ms1 = @SystemDir & "\msxml4.dll"
$verxp1 = "4.30.2100.0"
$verxp2 = "4.20.9876.0"


$ver = FileGetVersion($ms1)

If $ver <> $verxp2 Then
        $ans = MsgBox(1, "","Additional components are required.  Your Version is:  " & $ver )
    Else
        MsgBox(1, "","We are good to go!")
        Exit
EndIf

I just can't seem to check on 2 different file versions

Thank you for the help

Edited by gr1fter
Link to comment
Share on other sites

I cannot follow your logic here! What do you want to check exactly?

If you want to check whether $ver has version "4.20.9876.0" then you can do it with

If $ver = $verxp2 Then
    MsgBox(1, "","We are good to go!")
    Exit
Else
    $ans = MsgBox(1, "","Additional components are required. Your Version is: " & $ver )
EndIf

Or you want to check $verxp1 and $verxp2 you can do this:

If $ver = $verxp2 Then
    MsgBox(1, "","We are good to go!")
    Exit
ElseIf $ver = $verxp1
    MsgBox(1, "","File is newer!")
    Exit    
Else
    $ans = MsgBox(1, "","Additional components are required. Your Version is: " & $ver )
EndIf

Br,

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

I'll try to explain my logic.

I dont want to use =

I thought <> was the same as NOT

so i have two file versions. 1 file version = 4.30.2100.0 and the other file version = 4.20.9876.0

If i run this on a machine and I detect the following:

IF File Version (4.30.2100.0) is NOT there then say "Additional components are required."

IF File Version (4.20.9876.0) is NOT there then say "Additional components are required."

IF one of the File Version is (4.30.2100.0) OR (4.20.9876.0) THEN go head and say (We are good to go!)

The problem I am having is even though I DO have File Version (4.30.2100.0) or (4.20.9876.0) on the machine it is still telling me that I need "Additional components are required."

When it should be telling me "We are good to go"

Hope that makes sense! :mellow:

Link to comment
Share on other sites

You were almost there. 

If $ver <> $verxp1 Or $ver <> $verxp2 Then

should have been 

If $ver <> $verxp1 And $ver <> $verxp2 Then

$ms1 = @SystemDir & "\msxml4.dll"
$verxp1 = "4.30.2100.0"
$verxp2 = "4.20.9876.0"


$ver = FileGetVersion($ms1)

If $ver <> $verxp1 And $ver <> $verxp2 Then
        $ans = MsgBox(1, "","Additional components are required.  Your Version is:  " & $ver )
    Else
        MsgBox(1, "","We are good to go!")
        Exit
EndIf

"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook

Link to comment
Share on other sites

Or you can use this:

If $ver = $verxp1 OR $ver = $verxp2 Then
    MsgBox(1, "","We are good to go!")
    Exit
Else
    $ans = MsgBox(1, "","Additional components are required. Your Version is: " & $ver )
EndIf

BR,

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

You were almost there. 

If $ver <> $verxp1 Or $ver <> $verxp2 Then

should have been 

If $ver <> $verxp1 And $ver <> $verxp2 Then

$ms1 = @SystemDir & "\msxml4.dll"
$verxp1 = "4.30.2100.0"
$verxp2 = "4.20.9876.0"


$ver = FileGetVersion($ms1)

If $ver <> $verxp1 And $ver <> $verxp2 Then
        $ans = MsgBox(1, "","Additional components are required.  Your Version is:  " & $ver )
    Else
        MsgBox(1, "","We are good to go!")
        Exit
EndIf

That was it!

I dont know why i was insisted it being OR, it seemed like the right choice... THanks you all for the help!

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...