I have a problem with this VEX script.
@ create attributes instead of variables.
f[]@myList; // create list attribut
float pavW = 0.0;
for( int i = 1 ; i < 11 ; i++){
string path = "../widthPav" + itoa(i);
pavW = ch(path); // take the value in the specific channel
if (i == 1){
push(@myList,pavW); //add new component of value to myList
}
if ( pavW > 0){
foreach ( int j ; float value ; @myList){
if ( pavW == value){
break;
}else{
push(@myList,pavW); //add new component...
break;
}
}
}
}
I want to add pavW value to myList if pavW is different than the elements of myList. The result is not as expected.
In
foreachyou are comparing to the first element ofarrayonly. And for other elements yourifconditions fails and keeps on adding to themyList. You shouldpushto thearrayoutsideforeachblock.A temporary var named
uniquecan be used to trigger thepush.Suggestions:
foreach.Pythonexpression to get list of uniquewidthPavparm.Simple
Pythonsnippet: