Small question regarding variables and increasing them

Hello,

I currently want to write a script which creates a new variable from the internal variable !LOOP and increases it by 1 in every loop (so loop #2 is acutally #3, #3 is #4 and so on).

I do this by using the following line:

{
“Command”: “store”,
“Target”: “${!LOOP} + 2”,
“Value”: “customLoop”
}

However when taking a look at the variables tab, I get the following result for my variable:

CUSTOMLOOP: “1 + 2”

I think in order for my macro to work, I need an output of “3”.
How can I achieve this?

Thanks in advance for your help!

Hi

This is the macro code for your request

{
  "Name": "Loop",
  "CreationDate": "2019-10-16",
  "Commands": [
    {
      "Command": "executeScript_Sandbox",
      "Target": "return Number (${!Loop}) + 2",
      "Value": "CustomLoop"
    },
    {
      "Command": "echo",
      "Target": "${CustomLoop}",
      "Value": ""
    }
  ]
}

Log macro

[status]

Playing macro Loop

[info]

Executing:  | executeScript_Sandbox | return Number (${!Loop}) + 2 | CustomLoop | 

[info]

Executing:  | echo | ${CustomLoop} |  | 

[echo]

3

[info]

Macro completed (Runtime 4.30s)

[status]

Playing macro Loop

[info]

Executing:  | executeScript_Sandbox | return Number (${!Loop}) + 2 | CustomLoop | 

[info]

Executing:  | echo | ${CustomLoop} |  | 

[echo]

3

[status]

Current loop: 2

[info]

Executing:  | executeScript_Sandbox | return Number (${!Loop}) + 2 | CustomLoop | 

[info]

Executing:  | echo | ${CustomLoop} |  | 

[echo]

4

[status]

Current loop: 3

[info]

Executing:  | executeScript_Sandbox | return Number (${!Loop}) + 2 | CustomLoop | 

[info]

Executing:  | echo | ${CustomLoop} |  | 

[echo]

5

[status]

Current loop: 4

[info]

Executing:  | executeScript_Sandbox | return Number (${!Loop}) + 2 | CustomLoop | 

[info]

Executing:  | echo | ${CustomLoop} |  | 

[echo]

6

[status]

Current loop: 5

[info]

Executing:  | executeScript_Sandbox | return Number (${!Loop}) + 2 | CustomLoop | 

[info]

Executing:  | echo | ${CustomLoop} |  | 

[echo]

7

[info]

Macro completed (Runtime 21.27s)
2 Likes