If_v2 command problem

You need to use the Javascript “Number” conversion to make sure the string content is treated as number, and not as string. This works:

Number (${var1}) > Number (${var2}) + 200

Example:

{
  "Name": "greater",
  "CreationDate": "2019-9-23",
  "Commands": [
    {
      "Command": "store",
      "Target": "100",
      "Value": "var1"
    },
    {
      "Command": "store",
      "Target": "22",
      "Value": "var2"
    },
    {
      "Command": "if_v2",
      "Target": "Number (${var1}) > Number (${var2}) + 200",
      "Value": ""
    },
    {
      "Command": "echo",
      "Target": "var1 wins",
      "Value": "green"
    },
    {
      "Command": "else",
      "Target": "",
      "Value": ""
    },
    {
      "Command": "echo",
      "Target": "var2 wins",
      "Value": "blue"
    },
    {
      "Command": "end",
      "Target": "",
      "Value": ""
    }
  ]
}
1 Like