yongbin Posted November 13, 2012 Share Posted November 13, 2012 Hi. I want to use array attribute in vop with user's input. Can i set array attribute with user's input? I know that there isn't array parameter. But isn't there some trick? (eg. type converting from string) Thank you. Quote Link to comment Share on other sites More sharing options...
sho Posted November 13, 2012 Share Posted November 13, 2012 You can use split() function to create arrays from string input. string foo = "foo bar";string fooArray[] = split(foo);[/CODE] Quote Link to comment Share on other sites More sharing options...
yongbin Posted November 13, 2012 Author Share Posted November 13, 2012 (edited) Cool! How can I get int Array from "1 2 3 4 ..." ? Edited November 13, 2012 by yongbin Quote Link to comment Share on other sites More sharing options...
sho Posted November 13, 2012 Share Posted November 13, 2012 Well, you may need to do something like, string foo = "1 2 3 4";string fooArray[] = split($foo);int barArray[];foreach(int i; string s; $fooArray) { barArray[i] = atoi($s);}[/CODE] Quote Link to comment Share on other sites More sharing options...
yongbin Posted November 14, 2012 Author Share Posted November 14, 2012 Thank you sho! I tried int($foo) but not working. I didn't know that there is atoi() I am having hard time with vex. And you made my life easier. 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.