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

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Wish List
View previous topic :: View next topic  
Author Message
Nemroth
Guest





PostPosted: Thu Aug 26, 2004 5:01 pm    Post subject: if var [not] contains MatchList Reply with quote

Very good Idea, Chris,

but is it possible to add a parameter to say contains one of the parameters of the MatchList and contains all of the terms in the Match list, like

if var [not] contains [all] MatchList
Back to top
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10464

PostPosted: Thu Aug 26, 2004 5:39 pm    Post subject: Reply with quote

I thought about variations and whether they were worth the complexity. The simple approach seemed like it covers most uses.

The example you mentioned could be implemented as a series of IfInStrings:
Code:
IfInString, var, %string1%
     IfInString, var, %string2%
          MsgBox %var% contains both %string1% and %string2%.

In other words, the ability to AND things together is well covered by nesting more than one IF. But ORing things is harder, which is why I did "between", "in", and "contains" this way rather than some other.

Can you think of any other common needs that aren't covered by the existing commands?
Back to top
View user's profile Send private message Send e-mail
Nemroth
Guest





PostPosted: Thu Aug 26, 2004 6:09 pm    Post subject: Reply with quote

I'm OK with :
Code:
IfInString, var, %string1%
     IfInString, var, %string2%
          MsgBox %var% contains both %string1% and %string2%.
as I use this form in my script, but I think my proposition is more flexible.
Why ?
If I want to know if a string is in an other, I use :
Code:
IfInString, var, %string1%
     MsgBox %var% contains %string1%.

If I want to see if two strings are in an other, I use :
Code:
IfInString, var, %string1%
     IfInString, var, %string2%
          MsgBox %var% contains both %string1% and %string2%.
and if I want to know if 3 strings are in an other, I use :
Code:
IfInString, var, %string1%
     IfInString, var, %string2%
          IfInString, var, %string3%
                 MsgBox %var% contains both %string1%, %string2% and %string3%.

and so on...

For my use, 3 Gosub procedures...

If I use for example,
Code:
Compare = string1,string2,string3
If var contains all %Compare%

I don't need 3 Gosub procedures, as now, but only 2 lines of code....
I only have to change the number of coma separated strings to change the number of comparisons.
I think it's more concise and more elegant...
I hop you are agree with me...
Back to top
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10464

PostPosted: Thu Aug 26, 2004 6:39 pm    Post subject: Reply with quote

It's a valid example, but not nearly as common as wanting to do OR behavior. I try to balance simplicity against how often something is actually used in typical scripts. In this case, it seems like simplicity is better, especially since there is no way to support "all" unambigously (i.e. "all" could be part of the first search phrase in the list).

Also, it might please you to know that support for regular expressions in StringGetPos (and perhaps other commands) is on the to-do list. This "contains all" behavior can probably be done with that.

In the meantime, your example could be implemented this way:
Code:
Compare = string1,string2,string3
MatchFound = y  ; SetDefault
Loop, parse, Compare
IfNotInString, var, %A_LoopField%
{
     MatchFound = n
     break
}
Back to top
View user's profile Send private message Send e-mail
Nemroth
Guest





PostPosted: Thu Aug 26, 2004 6:48 pm    Post subject: Reply with quote

I think it would be a good thing to implement that feature, of course as I will use it !!! The syntaw could be anything else than [all]

But if you think regular expression in StringGetPos could be a better alternative, why not !!! I don't know.

For my point of vue, wait and see. Again thanks for the superb job on AHK...
Back to top
Nemroth
Guest





PostPosted: Thu Aug 26, 2004 7:16 pm    Post subject: Reply with quote

A last word : your procedure is better than my way to do, of course...
Back to top
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Wish List 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