KillianDS Posted March 12, 2022 Share Posted March 12, 2022 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 Quote Link to comment Share on other sites More sharing options...
Alain2131 Posted March 12, 2022 Share Posted March 12, 2022 (edited) 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 March 12, 2022 by Alain2131 Quote Link to comment Share on other sites More sharing options...
KillianDS Posted March 12, 2022 Author Share Posted March 12, 2022 it works perfectly! Thanks very much Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.