DigDeep Posted May 8, 2015 Share Posted May 8, 2015 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 More sharing options...
TheSaint Posted May 8, 2015 Share Posted May 8, 2015 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) Link to comment Share on other sites More sharing options...
Juvigy Posted May 8, 2015 Share Posted May 8, 2015 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 More sharing options...
DigDeep Posted May 8, 2015 Author Share Posted May 8, 2015 (edited) @ 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 May 8, 2015 by sunshinesmile84 Link to comment Share on other sites More sharing options...
DigDeep Posted May 8, 2015 Author Share Posted May 8, 2015 @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 More sharing options...
Developers Jos Posted May 8, 2015 Developers Share Posted May 8, 2015 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 TheSaint 1 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...
jguinch Posted May 8, 2015 Share Posted May 8, 2015 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) Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
Juvigy Posted May 8, 2015 Share Posted May 8, 2015 If $Date is something like '10/12/2015' and you are doing $Date > "10" - it wont work as expected and return the same result no matter how the date changes. Link to comment Share on other sites More sharing options...
TheSaint Posted May 8, 2015 Share Posted May 8, 2015 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) Link to comment Share on other sites More sharing options...
DigDeep Posted May 8, 2015 Author Share Posted May 8, 2015 @JosYes $Date value is DateDiff() here... that's why I gave it as > 10. which means "more than 10 days. Link to comment Share on other sites More sharing options...
Juvigy Posted May 8, 2015 Share Posted May 8, 2015 There is a great difference between$Date > "10"and$Date > 10 Link to comment Share on other sites More sharing options...
DigDeep Posted May 8, 2015 Author Share Posted May 8, 2015 (edited) @jguinchCorrecting 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 May 8, 2015 by sunshinesmile84 Link to comment Share on other sites More sharing options...
Juvigy Posted May 8, 2015 Share Posted May 8, 2015 This works:Select Case 11 > 10 OR 3 = 2 or 3<4 $Verify = "Appllication installed successfully." Case Else $Verify = "Appllication not exists." EndSelect ConsoleWrite($Verify&@CRLF)So the problem is with the values and types of your variables. As you can see OR is working perfectly Link to comment Share on other sites More sharing options...
DigDeep Posted May 8, 2015 Author Share Posted May 8, 2015 @JuvigyThis is little confusing... You are telling to use OR but when I check in SciTe, when I type in 'O' it suggests me to use Or. Link to comment Share on other sites More sharing options...
Juvigy Posted May 8, 2015 Share Posted May 8, 2015 OR=Or=or - it is all the sameSelect Case 9 > 10 Or 2 = 2 Or 5<4 $Verify = "Appllication installed successfully." Case Else $Verify = "Appllication not exists." EndSelect ConsoleWrite($Verify&@CRLF) Link to comment Share on other sites More sharing options...
sdfaheemuddin Posted May 9, 2015 Share Posted May 9, 2015 Can you use If Else statement Link to comment Share on other sites More sharing options...
sdfaheemuddin Posted May 9, 2015 Share Posted May 9, 2015 (edited) If $Date > "10" Or $ProcessVer = "2.5" Or $ProcessVer = '2.0' Or Not FileExists("FilePath") Then $Verify = "Appllication not exists." Else $Verify = "Appllication installed successfully." EndIf MsgBox(0, "", $Verify) Edited May 9, 2015 by sdfaheemuddin Link to comment Share on other sites More sharing options...
Geir1983 Posted May 9, 2015 Share Posted May 9, 2015 Isnt Case better suited to test an Integer value? "IF" more suited to this sort of boolean test? 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