| View previous topic :: View next topic |
| Author |
Message |
wolive
Joined: 20 Jul 2004 Posts: 21 Location: South Africa
|
Posted: Mon Nov 15, 2004 9:39 am Post subject: if Var contains MatchList |
|
|
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 |
|
 |
BoBo Guest
|
Posted: Mon Nov 15, 2004 10:15 am Post subject: |
|
|
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
|
Posted: Mon Nov 15, 2004 6:20 pm Post subject: |
|
|
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 |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10474
|
Posted: Mon Nov 15, 2004 9:23 pm Post subject: |
|
|
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 |
|
 |
wolive
Joined: 20 Jul 2004 Posts: 21 Location: South Africa
|
Posted: Thu Nov 18, 2004 6:36 am Post subject: |
|
|
| 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 |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10474
|
Posted: Thu Nov 18, 2004 12:29 pm Post subject: |
|
|
| 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 |
|
 |
Nemroth
Joined: 07 Sep 2004 Posts: 262 Location: France
|
Posted: Thu Nov 18, 2004 8:45 pm Post subject: |
|
|
| Good news. Thanks Chris. For my point of view, an AND option would be welcome. |
|
| Back to top |
|
 |
|