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 What?

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



Joined: 24 Jun 2004
Posts: 101
Location: Malta

PostPosted: Fri Apr 21, 2006 10:01 pm    Post subject: If var contains What? Reply with quote

Hi all!
Using If var contains is there a ahk varible that contains the match.

myvar = This is number two
matchvar = one,two,three

If myvar contains %matchvar%
msgbox, the matched item is %AND THIS IS WHERE I WANT TO DISPLAY WHICH ITEM IN MATCHVAR WAS MATCHED ONE TWO or THREE%

I realise that Loop-parsing the matchvar items can achieve this but in some cases I prefere to use if var contains

Any idea
Thanks all
Back to top
View user's profile Send private message
evl



Joined: 24 Aug 2005
Posts: 1238

PostPosted: Fri Apr 21, 2006 10:20 pm    Post subject: Reply with quote

Perhaps Chris could make ErrorLevel set to the matching item?
Back to top
View user's profile Send private message
bahri



Joined: 24 Jun 2004
Posts: 101
Location: Malta

PostPosted: Fri Apr 21, 2006 10:39 pm    Post subject: If var contains What? Reply with quote

Hi!
In fact that was the first thing I tried - the errorlevel - I thought may be I will find something not listed in the help file, but no joy.

How about it Chris? Errorlevel to hold the match ......
Thanks
bahri
Back to top
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10467

PostPosted: Sat Apr 22, 2006 2:25 am    Post subject: Reply with quote

Commands that don't currently change ErrorLevel cannot be changed to do so because it would break existing scripts that rely on the previous ErrorLevel being remembered.

In the future, better functions might get added to do this sort of thing. In the meantime, it's probably best to use something other than "contains" in cases like this.
Back to top
View user's profile Send private message Send e-mail
bahri



Joined: 24 Jun 2004
Posts: 101
Location: Malta

PostPosted: Sun Apr 23, 2006 12:26 am    Post subject: If var contains What? Reply with quote

Hi!
Very true Chris.
Will it be worthed adding a new ahk variable for this may be A_match?
I tend to use "If var contains" and "if var is" often as they cut down on the looping (although I suppose it's done internally anyway) and make lighter scripts

Thanks
bahri
Back to top
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10467

PostPosted: Sun Apr 23, 2006 9:27 am    Post subject: Reply with quote

Adding another built-in variable is possible but may be undesirable due to the sheer number of built-in variables, which burdens the documentation and complicates the code. However, there will probably be function/expression counterparts to "If Contains" and "If In" someday, which will probably have better capabilities.
Back to top
View user's profile Send private message Send e-mail
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