Jump to content

case selection with wild card or LIKE expression?


Recommended Posts

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!")
EndSelect

on $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

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 $var3

if the position is different of zero then position was found and so, string exists in string ! Posted Image

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...