Using an If to check that a string contains a certain substring

I’m new to Kantu and one of the things I’m trying to do with my first macro is click a certain area of the screen based on some text that is already there. I’ve stored the string in a variable (Description) and I now want to check it for a substring using an if statement. I’ve been trying several different ways to use a contains function, but I’m apparently failing to hit the right syntax.

So, what should my condition (Target:) be for the if statement if I want it to evaluate true when the variable includes the number 110?

Here is a code snippet to check that a string contains a certain substring. I copied the code from the DemoPDFTest_with_OCR macro that ships with Kantu.

{
      "Command": "storeEval",
      "Target": "var string = \"${q}\", substring = \"110\";  b= string.includes(substring); b;",
      "Value": "textfound"
    },
1 Like

Thank you! I went through several of the demos, but I don’t think I went through that one. I appreciate the help!

Update: Since UI.Vision Version 4 and newer, the easier solution is to use executeScript command and the Javascript .includes feature to check that a string contains a certain substring:

{
  "Name": "includes",
  "CreationDate": "2019-6-24",
  "Commands": [
    {
      "Command": "store",
      "Target": "test tim meyer",
      "Value": "e"
    },
    {
      "Command": "if_v2",
      "Target": "${e}.includes (\"tim\") == true",
      "Value": ""
    },
    {
      "Command": "echo",
      "Target": "yes, it contains this string",
      "Value": "blue"
    },
    {
      "Command": "end",
      "Target": "",
      "Value": ""
    }
  ]
}