TheUsualAlex Posted June 26, 2002 Share Posted June 26, 2002 Hi, I am learning to write my own custom expression funtion. Guess I didn't want to bother the List with such a kindergarten question. Is there any way to expand a variable in a vector(string type)? vector My_Function(val1, val2, val3) { vector Buffer = vector("[val1, 2, 3, val2, 1, val3, 7]"); return Buffer; } and since vector() is a string type, I couldn't assign my own number into the val*... Oh, I am not doing this for any project actually. Just as an exercise. Thanks. Quote Link to comment Share on other sites More sharing options...
Mario Marengo Posted June 28, 2002 Share Posted June 28, 2002 It's a little strange that you'd need a 7-component vector. I know this is just an exercise, but I don't think you'd see this very often in practice. Unless you're building an array - but even then the *caller* must be able to use it somehow... Anyway; for 3- or 4- component vectors you can use the vector3() and vector4() functions directly: return vector3(val1, val2, 3); return vector3(val1, val2, val3, 4); In your case, you're returning 7 components so you need to build the string for the generic vector() function. One way would be to use strcat(), like this: return vector( strcat(strcat(strcat(strcat(strcat(strcat("[",val1),", 2, 3, "),val2),", 1, "),val3),", 7]") ); Ugly! But AFAIK, the expression language doesn't have an sprintf() function yet... ----- Mario. Quote Link to comment Share on other sites More sharing options...
TheUsualAlex Posted June 29, 2002 Author Share Posted June 29, 2002 Whoa! I didn't know... (I am still learning. Thank you Mario. I will give it a try. 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.