dinodod Posted July 11, 2007 Share Posted July 11, 2007 I haven't come across any examples of a IF statement with an OR in the expression and I was wondering if anyone could advise me on what I need to do to make this work please. If (StringLeft($var, 2) <> "KB" or StringInStr($var, "Installshield") = 0) then $App = $App & Chr(13) & $var EndIfI've tried putting the () around each expression but that didn't work either. If (StringLeft($var, 2) <> "KB") or (StringInStr($var, "Installshield") = 0) thenThx! Digital Chaos - Life as we know it today.I'm a Think Tank. Problem is, my tank is empty.The Quieter you are, the more you can HearWhich would you choose - Peace without Freedom or Freedom without Peace?Digital Chaos Macgyver ToolkitCompletely Dynamic MenuSQLIte controlsAD FunctionsEXCEL UDFPC / Software Inventory UDFPC / Software Inventory 2GaFrost's Admin Toolkit - My main competitor :)Virtual SystemsVMWAREMicrosoft Virtual PC 2007 Link to comment Share on other sites More sharing options...
Developers Jos Posted July 11, 2007 Developers Share Posted July 11, 2007 what should it test for ? 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...
stampy Posted July 11, 2007 Share Posted July 11, 2007 I believe what you are looking for is more:if a=b or a=c or d=3 thenrather than if a=b or c thenthe complete expression is needed for all instances Link to comment Share on other sites More sharing options...
herewasplato Posted July 11, 2007 Share Posted July 11, 2007 See if this helps explain what your code is doing:$App = "app" $var = "KBInstallshield" MsgBox(0, "StringLeft", StringLeft($var, 2)) MsgBox(0, "StringInStr", StringInStr($var, "Installshield")) If StringLeft($var, 2) <> "KB" Or StringInStr($var, "Installshield") = 0 Then $App = $App & Chr(13) & $var EndIf MsgBox(0, "$App", $App)If $var = "KBInstallshield" then StringLeft($var, 2) <> "KB" will be false If $var = "KBInstallshield" then StringInStr($var, "Installshield") will return 3StringInStr($var, "Installshield") = 0 will be false3 = 0 will be falseIf both conditions are false, then $App = $App & Chr(13) & $var never executes.Change $var = "KBInstallshield" to $var = "KBInstall shield" and see what happens... [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
enaiman Posted July 11, 2007 Share Posted July 11, 2007 To explain how to look at OR and AND conditions you may consider this: True OR True = True True OR False = True False OR True = True False OR False = False True AND True = True True AND False = False False AND True = False False AND False = False SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script wannabe "Unbeatable" Tic-Tac-Toe Paper-Scissor-Rock ... try to beat it anyway :) Link to comment Share on other sites More sharing options...
Bert Posted July 11, 2007 Share Posted July 11, 2007 try this: If (StringLeft($var, 2) <> "KB" or if StringInStr($var, "Installshield") = 0) then $App = $App & Chr(13) & $var EndIf The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
tAKTelapis Posted July 11, 2007 Share Posted July 11, 2007 The OR part has always baffled me aswell: $a = 1 If $a = 2 OR $a = 3 Then MsgBox(0, "Ifs", "If statement true") EndIfoÝ÷ Ù8Z· +Çâì!z}7éoÝ÷ Ø mêÚ¶+Þ&§vwµêì¶)ejëh×6If $a OR $b = (2 OR 3 OR 4) Thanks to any and all who read that.. just remember folks, it does NOT actually work that way.. it works how all these other people have suggested /tAKTelapis Link to comment Share on other sites More sharing options...
MHz Posted July 12, 2007 Share Posted July 12, 2007 ...what I need to do to make this work please.What is the result that you expect? What is the value of $var? ...Switch to an alternative If needed. $a = 2 Switch $a Case 2, 3, 4 MsgBox(0, '', 'True') Case Else MsgBox(0, '', 'False') EndSwitch 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