Yehnfikm8Gq Posted January 21, 2010 Report Share Posted January 21, 2010 I'm trying to put together a series of Case statements but I want them to emulate "Contains". To do that I have to use wildcards with the Case string. By the looks of all the wildcard questions from Search, the most likely answer is that they cannot be used. Confirmation? If that's the case(!!), it's a shame that "Contains" is not an option in the Switch command. Quote Link to comment Share on other sites More sharing options...
kevin Posted January 21, 2010 Report Share Posted January 21, 2010 Yes, you are correct. Case statements do not have a 'wildcard' or 'contains' option. Because of their simplicity, Case statements may result in more concise macros than If statements. However, everything Case statements can do can also be accomplished using If statements. And If statements have a 'contains' option. Quote Link to comment Share on other sites More sharing options...
paul Posted January 21, 2010 Report Share Posted January 21, 2010 I'm trying to put together a series of Case statements but I want them to emulate "Contains". To do that I have to use wildcards with the Case string. By the looks of all the wildcard questions from Search, the most likely answer is that they cannot be used. Confirmation? If that's the case(!!), it's a shame that "Contains" is not an option in the Switch command. If your search strings are always at the beginning, then you could do a Case statement on the first n characters, followed by If statements within each Case statement. Quote Link to comment Share on other sites More sharing options...
Yehnfikm8Gq Posted January 21, 2010 Author Report Share Posted January 21, 2010 ......Because of their simplicity, Case statements may result in more concise macros than If statements. However, everything Case statements can do can also be accomplished using If statements. And If statements have a 'contains' option. Unfortunately my current exercise is to replace If statements where possible and to use Case more in the future. Quote Link to comment Share on other sites More sharing options...
paul Posted January 22, 2010 Report Share Posted January 22, 2010 Unfortunately my current exercise is to replace If statements where possible and to use Case more in the future. Well, another idea pops to mind. Why not pass the string you're searching on plus all the possible sequences you would have put in your Case statements to AutoIt for evaluation, use StringInString to evaluate, and return the relevant number. For example, instead of: select case Searchstring case "fox" case "rabbit" case "wolf" case else have AutoIt return 1 for fox, 2 for rabbit, 3 for wolf, 4 for all other cases, then build your MEP Case statement accordingly. Quote Link to comment Share on other sites More sharing options...
Yehnfikm8Gq Posted January 28, 2010 Author Report Share Posted January 28, 2010 Well, another idea pops to mind.......have AutoIt return 1 for fox, 2 for rabbit, 3 for wolf, 4 for all other cases, then build your MEP Case statement accordingly. Sorry for my late response. The idea is to simplify macros with numerous Ifs. Going off to AutoIt doesn't fit the bill although it's a neat solution. There's no reason why Case can't have the same options as If (as if it can't!), but I suppose it operates per other applications. It's much clearer seeing a list of alternative returns than a bunch of nested Ifs. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.