How to count the number of options into a select?

Hello,

Thank you for your answer.

For the moment, I have made this code in ui.vision to init the index with “i” variable. Then I do a loop where I increment the “i” variable, and where I would to get an array of the options values.

This is the actual code (with executeScript command) :

{
“Name”: “test3”,
“CreationDate”: “2020-9-2”,
“Commands”: [
{
“Command”: “executeScript”,
“Target”: “i = 1; return i;”,
“Value”: “i”
},
{
“Command”: “echo”,
“Target”: “My first value is ${i}”,
“Value”: “”
},
{
“Command”: “while_v2”,
“Target”: “${i} < 10”,
“Value”: “”
},
{
“Command”: “executeScript”,
“Target”: “return (${i}) + 1”,
“Value”: “i”
},
{
“Command”: “echo”,
“Target”: “My new value is ${i}”,
“Value”: “”
},
{
“Command”: “end”,
“Target”: “”,
“Value”: “”
},
{
“Command”: “echo”,
“Target”: “The end”,
“Value”: “”
}
]
}

And then I would re-use the array with the option values to select randomly one of these values with select command.

The actual script is functional, but I have a problem on my own website : if I launch this script on it, there is an error for the executeScript command, because there is a security implemented for javascript commands and I cannot do anything to change this. The executeScript cannot be used because if it was, it would be possible to inject some code through it…

If I launch the code with executeScript command like written, I have this error :

Error in executeScript code: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "script-src 'self' 'unsafe-inline'". ui.vision

So, I think I have to use another command than executeScript.

And so I have made this code with store command :

{
“Name”: “test3”,
“CreationDate”: “2020-9-2”,
“Commands”: [
{
“Command”: “store”,
“Target”: “1”,
“Value”: “i”
},
{
“Command”: “echo”,
“Target”: “My first value is ${i}”,
“Value”: “”
},
{
“Command”: “while_v2”,
“Target”: “${i} < 10”,
“Value”: “”
},
{
“Command”: “executeScript”,
“Target”: “return (${i}) + 1”,
“Value”: “i”
},
{
“Command”: “echo”,
“Target”: “My new value is ${i}”,
“Value”: “”
},
{
“Command”: “end”,
“Target”: “”,
“Value”: “”
},
{
“Command”: “echo”,
“Target”: “The end”,
“Value”: “”
}
]
}

This code is launched successfully but the valeur is a text, not an integer… So it is not incremented like I would… And I don’t know how to parse my string variable to an integer.

For the moment, the ${i] is incremented like that so : i=1, Loop 1 : i=11...

The ParseInt(${i}) doesn’t work or I don’t know how to use it correctly. Is it possible ?

Thanks in advanced