AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

If var [not] in false match

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Bug Reports
View previous topic :: View next topic  
Author Message
tic



Joined: 22 Apr 2007
Posts: 1271

PostPosted: Tue Apr 01, 2008 4:53 pm    Post subject: If var [not] in false match Reply with quote

Code:
a := 20
b := 30
c := ""
d := ""

Var := 30

If Var not in %a%,%b%,%c%,%d%
MsgBox, Should not match here
Else
MsgBox, It is in it though!


The "expression" says:

Code:
If 30 not in 20,30,,


however 30 is in it, but we get in the above code that it is not, just because we are matching with 2 blank variables.

If we change it to:

Code:
If Var not in %a%,%b%,%c%


it will work fine. This is not expected behaviour as 30 is never contained in [blank] ??
Back to top
View user's profile Send private message
Superfraggle



Joined: 02 Nov 2004
Posts: 753
Location: London, UK

PostPosted: Tue Apr 01, 2008 5:21 pm    Post subject: Reply with quote

I believe this is interpreting the list as such

20
30,
therefore 30 doesnt exist, but 30, does
_________________
Steve F AKA Superfraggle

http://r.yuwie.com/superfraggle
Back to top
View user's profile Send private message MSN Messenger
tic



Joined: 22 Apr 2007
Posts: 1271

PostPosted: Tue Apr 01, 2008 5:25 pm    Post subject: Reply with quote

Interesting thought. That seems quite likely. However, I dont think it should do this. It should only do that for `, not ,

It becomes very annoying using if [not] in as then you have to check all the variables are not empty, which defeats the purpose of using it (to save lines)
Back to top
View user's profile Send private message
Superfraggle



Joined: 02 Nov 2004
Posts: 753
Location: London, UK

PostPosted: Tue Apr 01, 2008 5:32 pm    Post subject: Reply with quote

for some reason this works different with commas.

Quote:
Two consecutive commas results in a single literal comma. For example, the following would produce a single literal comma at the end of string1: If Var In string1,,,string2. Similarly, the following list contains only a single item with a literal comma inside it: If Var In single,,item. To include a blank item in the list, make the first character a comma as in this example: If Var In ,string1,string2 (when using the "contains" operator, a blank item will always result in a match since the empty string is found in all strings).

_________________
Steve F AKA Superfraggle

http://r.yuwie.com/superfraggle
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Bug Reports All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group