| View previous topic :: View next topic |
| Author |
Message |
bahri
Joined: 24 Jun 2004 Posts: 101 Location: Malta
|
Posted: Fri Apr 21, 2006 10:01 pm Post subject: If var contains What? |
|
|
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 |
|
 |
evl
Joined: 24 Aug 2005 Posts: 1238
|
Posted: Fri Apr 21, 2006 10:20 pm Post subject: |
|
|
| Perhaps Chris could make ErrorLevel set to the matching item? |
|
| Back to top |
|
 |
bahri
Joined: 24 Jun 2004 Posts: 101 Location: Malta
|
Posted: Fri Apr 21, 2006 10:39 pm Post subject: If var contains What? |
|
|
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 |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10467
|
Posted: Sat Apr 22, 2006 2:25 am Post subject: |
|
|
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 |
|
 |
bahri
Joined: 24 Jun 2004 Posts: 101 Location: Malta
|
Posted: Sun Apr 23, 2006 12:26 am Post subject: If var contains What? |
|
|
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 |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10467
|
Posted: Sun Apr 23, 2006 9:27 am Post subject: |
|
|
| 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 |
|
 |
|