gr1fter Posted April 25, 2011 Share Posted April 25, 2011 Hello, I was wondering if I could get help on Case expressions. I understand the logic behind exact matches but I could use some help on Case with Like statements.Here is an example:Select Case $var = "Model 1" MsgBox(0, "", "First Case expression was true") Case $var2 = "Model 2" MsgBox(0, "", "Second Case expression was true") Case $var3 = "Model 345923928039823908233ABCDEFGHIJKLMNOP" MsgBox(0, "", "Third Case expression was true") Case Else MsgBox(0, "", "No preceding case was true!") EndSelecton $var3 i would like to detect that Case by a LIKE statement for the long Variable. Maybe only read the Model 3 or Model 345 and it is a match. Thanks for any help provided Link to comment Share on other sites More sharing options...
wakillon Posted April 25, 2011 Share Posted April 25, 2011 Try Case StringInstr ( $var3, "Model " ) <> 0 AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts Link to comment Share on other sites More sharing options...
gr1fter Posted April 25, 2011 Author Share Posted April 25, 2011 Try Case StringInstr ( $var3, "Model " ) <> 0 That works great thank you very much, I understand StringInstr part but can you explain to me the <> 0 part and why that there makes it work. Link to comment Share on other sites More sharing options...
wakillon Posted April 25, 2011 Share Posted April 25, 2011 That works great thank you very much, I understand StringInstr part but can you explain to me the <> 0 part and why that there makes it work.StringInstr returns the position of "Model " in $var3if the position is different of zero then position was found and so, string exists in string ! AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts Link to comment Share on other sites More sharing options...
gr1fter Posted April 25, 2011 Author Share Posted April 25, 2011 StringInstr returns the position of "Model " in $var3if the position is different of zero then position was found and so, string exists in string ! I got it now. Thank you very much! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now