rbesca Posted March 28, 2020 Share Posted March 28, 2020 (edited) i@iterations = len(chs("../NETWORK_CONTROLLER/c2p_querstrbn")); s@myArray = chs("../NETWORK_CONTROLLER/c2p_querstrbn"); i[]@myintArray = {}; s[]@mystrArray = {}; //remove spaces from string array, get len() of string array if (i@iterations >2) { i@iterations += 1; i@iterations /= 2; } //create arrays from preselection int i; for(i=0; i < i@iterations*2; i++) { i@stringtointeger = atoi(s@myArray[i]); append(i@myintArray, i@stringtointeger); } // remove spaces from int Array i[]@cleanArray = i@myintArray[0::2]; // convert back to string to read in with copy to points target points later for(i=0; i < i@iterations; i++) { s@integertostring = itoa(s@mystrArray[i]); append(i@mystrArray, s@integertostring); } hey all, vex noob here. I am trying to append values from an integer array to a string array. looping over array entries with atoi works fine to extract the strings and append them to an int array. but the other way around using itoa gives me this error: Warning: Errors or warnings encountered during VEX compile: /obj/geo1/pointwrangle4/attribvop1/snippet1: Call to undefined array index operator 'int string[][int]'. (33,53). Error: Error in VOP 'snippet1'. Warning: Errors or warnings encountered during VEX compile: /obj/geo1/pointwrangle4/attribvop1/snippet1: Call to undefined array index operator 'int string[][int]'. (33,53). Error: Vex error: /obj/geo1/pointwrangle4/attribvop1/snippet1: Call to undefined array index operator 'int string[][int]'. (33,53) i'll try to sum up the context quickly: I have a controller node where I can enter the points I want to copy objects to. now when I copy to point 0 1 2 3, another copy node should copy other objects to points 4 5 6 7. when I enter 0 1 2, the other copy should go to 3 4 5 etc. Edited March 28, 2020 by rbesca Quote Link to comment Share on other sites More sharing options...
anim Posted March 28, 2020 Share Posted March 28, 2020 (edited) while I don't completely understand what you are going for, but this s@integertostring = itoa(s@mystrArray[i]); should probably be this, as you aferall want to convert int to string s@integertostring = itoa(i@cleanArray[i]); but I doubt it will help your code as you are clearly dealing with strings and want output as a string not string array, what exactly are you trying to do? Why would someone enter only sequential 0 1 2 3, what if user enters 0 3 4 6? what would you expect the rest to be? 1 2 5 7? what if there is not 8 points in the geo? sounds like too many assumptions usually you want to use groups for this, you pick your points as group A and then one copy uses group A and another !A if however you still want to pursue VEX then have a look at functions like split() and join() to avoid unnecesary code, also you may want to use variables instead of attribute bindings unless you want the values to be atually output into an attribute Edited March 28, 2020 by anim 1 Quote Link to comment Share on other sites More sharing options...
rbesca Posted March 28, 2020 Author Share Posted March 28, 2020 (edited) I'm sorry I said that wrong, yes I originally have a string not a string array. if someone would enter 0 3 4, i would want to copy to 0 1 2 and 3 4 5. so take a string, len(), clean the spaces and use that length to create two lists of that length but one should be offset by the length. then I want to use that string as my target points Edited March 28, 2020 by rbesca Quote Link to comment Share on other sites More sharing options...
anim Posted March 28, 2020 Share Posted March 28, 2020 why not just taking integer number then? if user enters 3, one group will be 0 1 2 and another 3 4 5 ir in another words if you have integer paramerer "n" then one group field will be: 0-`ch("n")-1` and another: `ch("n")`-`ch("n")*2-1` 1 Quote Link to comment Share on other sites More sharing options...
rbesca Posted March 28, 2020 Author Share Posted March 28, 2020 I honestly just didn't think of using groups... this looks like a much better way to do this Quote Link to comment Share on other sites More sharing options...
anim Posted March 28, 2020 Share Posted March 28, 2020 don't have to be groups, just directly put it in target points group field of Copy SOPs if you want to create groups first you may find Group By Range handy as you are just creating 2 range groups Quote Link to comment Share on other sites More sharing options...
rbesca Posted March 28, 2020 Author Share Posted March 28, 2020 okay so the user input could still be 0 3 4 with using a ch() it doesn't need to be a direct input of 3, I can just get the length of my string, make it an int "n" parameter and set as I wish and then get that value with ch("../mynode/"n"")? Quote Link to comment Share on other sites More sharing options...
rbesca Posted March 28, 2020 Author Share Posted March 28, 2020 (edited) alright I'm using point() to get my iteration count now and it's working thank you tomas, have a safe time! I think what made this so complicated for me was that I forgot that you can type in 0-3 instead of 0 1 2 3 which makes this a lot easier to type the way you did instead of trying to do unnecessary things with arrays and vex Edited March 28, 2020 by rbesca 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.