Create list of variables with no hardcode (VEX, Python?... )

   1643   4   2
User Avatar
Member
34 posts
Joined: Jan. 2017
Offline
How to create a list of variables, as well attributes, like myVar1, myVar2, myVar3, etc, with no hardcode?

What I find:

//Variables:
string myVar1 = "text1";
string myVar2 = "text2";
string myVar3 = "text3";
//...

//Attributes:
s@myAttrib1 = myVar1;
s@myAttrib2 = myVar2;
s@myAttrib3 = myVar3;
//...

What I tried:

int i = 0;

for (i=0; i<5; i++);
    string myVar+itoa(i) = "text+"itoa(i);
    s@myAttrib+itoa(i) = myVar+itoa(i);

It seems only works for string value, and not at time variable/attrib creation.

Thanks!
Edited by AlbertoGZ - Oct. 15, 2022 07:44:06
User Avatar
Member
900 posts
Joined: Feb. 2016
Offline
setpointattrib() and similar functions might be helpful in this case
https://www.sidefx.com/docs/houdini/vex/functions/setpointattrib.html [www.sidefx.com]
User Avatar
Member
34 posts
Joined: Jan. 2017
Offline
Thank you Andr, but it seems only create one attrib with the last number in the loop.

Attachments:
Captura de pantalla 2022-10-15 a las 16.19.43.png (459.8 KB)

User Avatar
Member
34 posts
Joined: Jan. 2017
Offline
My mistake with ; at the end of line in the for loop :P
Edited by AlbertoGZ - Oct. 15, 2022 10:29:00

Attachments:
Captura de pantalla 2022-10-15 a las 16.27.59.png (647.3 KB)

User Avatar
Member
85 posts
Joined: May 2011
Offline
int i = 0;

for (i=0; i<5; i++)
{
setpointattrib(0, "my_var_" + itoa(i), @ptnum, itoa(i), "set");
}
— dedeks 3000 —
  • Quick Links