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 contains MatchList

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
wolive



Joined: 20 Jul 2004
Posts: 21
Location: South Africa

PostPosted: Mon Nov 15, 2004 9:39 am    Post subject: if Var contains MatchList Reply with quote

How can I use (if possible) the "if Var contains MatchList" statements to reduce the following code snippet:

IfEqual, lh_Str2, X0002
Continue

IfEqual, lh_Str2, X0003
Continue

IfEqual, lh_Str2, X0006
Continue


Thanks
Back to top
View user's profile Send private message
BoBo
Guest





PostPosted: Mon Nov 15, 2004 10:15 am    Post subject: Reply with quote

if Var contains MatchList

Quote:
If lh_Str2 contains X0002,X0003,X0006
Continue


Should make it.
Back to top
Nemroth



Joined: 07 Sep 2004
Posts: 262
Location: France

PostPosted: Mon Nov 15, 2004 6:20 pm    Post subject: Reply with quote

Not necessary
If you want to know if one of X0002, X0003 or X0006 is in lh_Str2, I think it's OK
But if you want to know if X0002, X0003 and X0006 are in lh_Str2, I think it's not OK
In the Help you see that :
Quote:
If var [not] in value1,value2,... [v1.0.18+]
If var [not] contains value1,value2,... [v1.0.19+]
Checks whether a variable's contents match one of the items in a list.

So in :
Code:
If lh_Str2 contains X0002,X0003,X0006
, the condition is true if only one of X0002, X0003 or X0006 is in lh_Str2.
I asked a question in the if var [not] contains MatchList topic
I hope it's helpfull.
Back to top
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10474

PostPosted: Mon Nov 15, 2004 9:23 pm    Post subject: Reply with quote

From the original post, it sounded like "or" behavior was desired, so I think it's okay.

In addition, it seems like "in" is better than "contains" in this case, because "IfEqual" was used in the original request. If true, the ideal answer is probably:
Code:
If lh_Str2 in X0002,X0003,X0006
     Continue
Back to top
View user's profile Send private message Send e-mail
wolive



Joined: 20 Jul 2004
Posts: 21
Location: South Africa

PostPosted: Thu Nov 18, 2004 6:36 am    Post subject: Reply with quote

Thanks for the help. The original behavior I was after was indeed based on OR. If an AND behaviour was available as described by Nemroth I definately would use it particularly when using it in scripts that convert text files from one format to another based on line and field content.
Back to top
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10474

PostPosted: Thu Nov 18, 2004 12:29 pm    Post subject: Reply with quote

Quote:
If an AND behaviour was available as described by Nemroth I definately would use it
Thanks for the feedback. Support for regular expressions is planned, which I think should cover the need for "and" behavior.
Back to top
View user's profile Send private message Send e-mail
Nemroth



Joined: 07 Sep 2004
Posts: 262
Location: France

PostPosted: Thu Nov 18, 2004 8:45 pm    Post subject: Reply with quote

Good news. Thanks Chris. For my point of view, an AND option would be welcome.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help 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