# Use value of i in for loop

## Recommended Posts

Hello!
In Attribute Wrangle I did:
vector x = {1,2,3};

int i = 1;

vector y = set(x1); // this makes @y={1,2,3}
Can I did it in other way to get the same result?:
vector y = set(x); // here x should became x1

##### Share on other sites
Posted (edited)

set() is how you populate a vector variable. It requires 3 values. You don't use set() to set one variable equal to another, just use the equals symbol =

```// braces are used only for constants and can not support variables.
vector v = {1,2,3};

// set() is used for constant or variable style vector construction.
float x = 1.0;
float y = 2.0;
vector v = set(x,y,3.0);

// equals is for assignment.
x = y;
vector v = set(x,x,x);```

Edited by Atom

##### Share on other sites
40 minutes ago, Atom said:

set() is how you populate a vector variable. It requires 3 values. You don't use set() to set one variable equal to another, just use the equals symbol =

```
// braces are used only for constants and can not support variables.
vector v = {1,2,3};

// set() is used for constant or variable style vector construction.
float x = 1.0;
float y = 2.0;
vector v = set(x,y,3.0);

// equals is for assignment.
x = y;
vector v = set(x,x,x);```

I badly explained what I want,sory(
Here is what I meant:
I have vectors variable which have numbers in theirs names (x1,x2,x3 etc). And I have an integer variable/variables (i = 1,2,3 etc.).
So my goal is to call the vector variable in a loop:
for (int i =1; i<4; i++){

vector y = set(x`i`)  - here I want Houdini commits this expression like "set(x1)" and value of x1 should assained to y.

##### Share on other sites
Posted (edited)

No need for any of that then.

```vector x1 = set(1,2,3);
vector y = x1;```

I don't think you can construct a variable name as a string and then operate upon it as if it was a variable. You may want to review the VEX language syntax and functions.

Edited by Atom
• 1