Yokho Posted March 7, 2006 Share Posted March 7, 2006 Hello, so here's my problem; I am trying to compare 4 variables, 2 sets of them (var1 vs var2, and var3 vs var4) Here's my actual line: If $var1 <> $var2 And $var3 <> $var4 then MsgBox(4, "title", "select yes if the informations need adjusting") EndIf Now , my problem is, i only want the message box to pop up when var1 isnt like var2, AND var3 isnt like var4, but at the moment, as soon as 1 of the 2 sets isnt matching, the message box pops up. Anyone know why? I am pretty new to programming so i might be missing something obvious, but i thought that the AND i put there would make the pop up window pop ONLY if BOTH sets of variables were different ( I tried ($var1 <> $var2) And ($var3 <> $var4) then, and also tried ($var1 <> $var2 And $var3 <> $var4) then, but neither worked) Also, when both variable sets are matching, the pop up window doesn't pop, as intended. Anyone got any clue as to what im doing wrong? Link to comment Share on other sites More sharing options...
Developers Jos Posted March 7, 2006 Developers Share Posted March 7, 2006 (edited) Hello, so here's my problem;I am trying to compare 4 variables, 2 sets of them (var1 vs var2, and var3 vs var4)Here's my actual line: If $var1 <> $var2 And $var3 <> $var4 then MsgBox(4, "title", "select yes if the informations need adjusting")EndIfNow , my problem is, i only want the message box to pop up when var1 isnt like var2, AND var3 isnt like var4, but at the moment, as soon as 1 of the 2 sets isnt matching, the message box pops up. Anyone know why? I am pretty new to programming so i might be missing something obvious, but i thought that the AND i put there would make the pop up window pop ONLY if BOTH sets of variables were different ( I tried ($var1 <> $var2) And ($var3 <> $var4) then, and also tried ($var1 <> $var2 And $var3 <> $var4) then, but neither worked) Also, when both variable sets are matching, the pop up window doesn't pop, as intended.Anyone got any clue as to what im doing wrong?If statement is correct .... WHat are the values of the 4 variables when it isn't working ?Important to tell us if they are strings or Numbers .... Edited March 7, 2006 by JdeB 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...
Valuater Posted March 7, 2006 Share Posted March 7, 2006 1 Welcome to Autoit 2 Works for me $var1 = 2 $var2 = 1 $var3 = 1 $var4 = 1 If $var1 <> $var2 And $var3 <> $var4 then MsgBox(4, "title 1", "select yes if the informations need adjusting") EndIf $var1 = 1 $var2 = 1 $var3 = 2 $var4 = 1 If $var1 <> $var2 And $var3 <> $var4 then MsgBox(4, "title 2", "select yes if the informations need adjusting") EndIf $var1 = 2 $var2 = 1 $var3 = 2 $var4 = 1 If $var1 <> $var2 And $var3 <> $var4 then MsgBox(4, "title 3", "select yes if the informations need adjusting") EndIf 8) Link to comment Share on other sites More sharing options...
Yokho Posted March 7, 2006 Author Share Posted March 7, 2006 1 Welcome to Autoit 2 Works for me $var1 = 2 $var2 = 1 $var3 = 1 $var4 = 1 If $var1 <> $var2 And $var3 <> $var4 then MsgBox(4, "title 1", "select yes if the informations need adjusting") EndIf $var1 = 1 $var2 = 1 $var3 = 2 $var4 = 1 If $var1 <> $var2 And $var3 <> $var4 then MsgBox(4, "title 2", "select yes if the informations need adjusting") EndIf $var1 = 2 $var2 = 1 $var3 = 2 $var4 = 1 If $var1 <> $var2 And $var3 <> $var4 then MsgBox(4, "title 3", "select yes if the informations need adjusting") EndIf 8) Alrighty, My values are strings, and when the script doesn't work, its because only one of the sets don't match, while i want the window to pop only if BOTH dont match. Hope that helps. Link to comment Share on other sites More sharing options...
Developers Jos Posted March 7, 2006 Developers Share Posted March 7, 2006 Alrighty, My values are strings, and when the script doesn't work, its because only one of the sets don't match, while i want the window to pop only if BOTH dont match. Hope that helps.The If you posted will ONLY be true when both sets are not equal...Give us an example of values that have the problem ..... 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...
CyberSlug Posted March 7, 2006 Share Posted March 7, 2006 The only thing I can think of is if Yokho wants to do a case-sensitive comparision.In that case, of course, the required code would beIf (Not ($var1 == $var2)) And (Not ($var3 == $var4)) Then Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig! Link to comment Share on other sites More sharing options...
Altalus Posted March 7, 2006 Share Posted March 7, 2006 Hi ppl, Yokho is actually a cow-worker of mine and I found out the problem with him. Being new to programming he forgot to check his strings for extra spaces " " Thanks for the replies ! Link to comment Share on other sites More sharing options...
Yokho Posted March 7, 2006 Author Share Posted March 7, 2006 The only thing I can think of is if Yokho wants to do a case-sensitive comparision.In that case, of course, the required code would beIf (Not ($var1 == $var2)) And (Not ($var3 == $var4)) Then*ashamed* Argh... i'm sorry guys, in fact, there was a problem with the compilation of one of my values, it had a space that wasn't supposed to be there, which made the first set always different. That'll teach me to not look character by character when i do my debug tests ><Sorry! And thanks for the support, it helped me with another problem i was having with the case sensitive problem! 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