Decrement a variable into a loop

Hello,

I’m trying to decrement a variable into a loop into ui.vision, but I have an error.

The code :

{
  "Command": "executeScript_Sandbox",
  "Target": "return Math.floor(Math.random()*(10-1+1))+1;",
  "Value": "nb"
},
{
  "Command": "do",
  "Target": "",
  "Value": ""
},
{
  "Command": "executeScript_Sandbox",
  "Target": "return --${nb};",
  "Value": ""
},
{
  "Command": "echo",
  "Target": "${nb}",
  "Value": ""
},
{
  "Command": "repeatIf",
  "Target": "${nb}>0",
  "Value": ""
}

The error seen after play macro :

Error in executeScript_Sandbox code: Invalid left-hand side expression in prefix operation

If I try another solutions, like this for example, I have also an error :
> {

  "Command": "executeScript_Sandbox",
  "Target": "return ${nb}--;",
  "Value": ""
}

Or

{
  "Command": "executeScript_Sandbox",
  "Target": "${nb} = ${nb}-1; return ${nb};",
  "Value": ""
}

Which the error is :

Error in executeScript_Sandbox code: Invalid left-hand side in assignment

Did you know how to do this without error ?

Thank you in advanced

Use a command like this

{
“Command”: “executeScript_Sandbox”,
“Target”: “return Number (${Loop_Counter}) - 1”,
“Value”: “Loop_Counter”
},

2 Likes