Jump to content

OR statement not working


Recommended Posts

Not sure, what is wrong with the below statement that it always shows the msgbox as: Application installed successfully.

Is there anything wrong to write the OR statement as per below or any improvised way to write it?

Select
        Case $Date > "10" Or $ProcessVer = "2.5" Or $ProcessVer = '2.0' Or Not FileExists("FilePath")
            $Verify = "Appllication not exists."
        Case Else
            $Verify = "Appllication installed successfully."
    EndSelect
    
    MsgBox(0, "", $Verify)

 

Link to comment
Share on other sites

Perhaps you need to use AND or nest some elements together in brackets?

Using ELSE on its own is pretty ambiguous, and is always the case that is true, if none of the first case is true.

Not knowing the rest of your code etc it is hard to gauge where you might have an issue.

From my point of view, "FilePath" has no meaning, as like it is, it isn't a path.

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to comment
Share on other sites

What is the value of $Date ? Put a checkbox or consolewrite to see the value. Also the type is important - sometimes Autoit converts between number and string and comparison is very different than what you would expect.

Link to comment
Share on other sites

@ TheSaint

This is a dummy example I have shows here so I have just mentioned as "FilePath". In the actual code, filepath has the correct value of the path where file should exist.

So, what you are suggesting is to mention as per below?

$Date > "10"
$ProcessVer = "2.5"
$ProcessVer = "2.0" 
$File = FileExists("FilePath")

Select
        Case Not $Date And $ProcessVer And $File
            $Verify = "Appllication not exists."
        Case $Date And $ProcessVer And $File
            $Verify = "Appllication installed successfully."
    EndSelect
    
    MsgBox(0, "", $Verify)

 

 

Edited by sunshinesmile84
Link to comment
Share on other sites

@Juvigy

$Date is the date modified of a particular file.

If I write these individually then it works properly. But if I write them in multiples of OR that when it does not identify.

What I am looking with the OR statement is... it would check all the fields.. if $Date is more or Version is not equal to 2.5 or 2.0 or the file itself does not exist then will display the message as "App does not exist."

 

; This is another way the code works propelry. But this makes the codes larger.

Select
        Case $Date > "10" 
            $Verify = "Appllication not exists."
        Case $ProcessVer = "2.5" 
            $Verify = "Appllication not exists."        
        Case $ProcessVer = '2.0'
            $Verify = "Appllication not exists."        
        Case Not FileExists("FilePath")
            $Verify = "Appllication not exists."
            
        Case Else
            $Verify = "Appllication installed successfully."
    EndSelect
    
    MsgBox(0, "", $Verify)

 

Link to comment
Share on other sites

  • Developers

This doesn't look right:

$Date > "10"

What is the exact content of date and you are doing a greater than test with the String 10!
When it contains a proper date value you could compare it to another date value with DateDiff() or something.

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

Try to use number instead of string for comparisons :

Select
    Case Number($Date) > 10 And Number($ProcessVer) = 2 And FileExists("FilePath")
        $Verify = "Appllication installed successfully."
    Case Else
        $Verify = "Appllication not exists."
EndSelect
    
MsgBox(0, "", $Verify)

 

Link to comment
Share on other sites

How did I miss the string "10" ? :>

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to comment
Share on other sites

@jguinch

Correcting your code little bit. '<' instead of '>' :)

But by putting And statement... does this not mean that only if all the 3 checks are true that $Date is less than 10 And Version is = 2 and File exists then it would pass ?

What I needed was if any of the 3 checks are false then it would fail else success.

 

Select
    Case Number($Date) < 10 And Number($ProcessVer) = 2 And FileExists("FilePath")
        $Verify = "Appllication installed successfully."
    Case Else
        $Verify = "Appllication not exists."
EndSelect
    
MsgBox(0, "", $Verify)

Edited by sunshinesmile84
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...