Jump to content

Vector with array[x] doesn't work


Recommended Posts

Helloo !
I can't understand why I can't put my "list[c]" in my vector variable here is my script in attribut wrangle:


float list[];
vector distanceListDetail[];
	list= {1,2,3,4,5};
distanceListDetail = {{1,1,22},{2,3,1},{1,2,3},{3,2,1},{0,1,0}};
	for (int c = 0; c < len(list); c++)
{
    printf("%f\n", list[c]);
    vector test = { 0,list[c], 0};
	    push(distanceListDetail, test);
}


the problem is here it gives me an error and I can't understand why even by setting the value by hand it works if someone can help me : vector test = { 0,list[c], 0};


thanks for your help
Killian

Link to comment
Share on other sites

Hello Killian,

The error is at line 8.

vector test = { 0,list[c], 0};

This is because VEX doesn't allow you to put variables into curly brackets {}.
I don't know the reason, but I would guess it has something to do with optimisation and knowing the value beforehand. Don't quote me on that.

Use the set() function instead, it takes care of that.

vector test = set( 0, list[c], 0);
Edited by Alain2131
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...