Jump to content

VEX supports array function?


ciel9979

Recommended Posts

Hi, this is my first post here. :)

I've been trying to call a vector array function in VEX, but it either returned "Internal Compiler Error" or "Syntax error, unexpected identifier, expecting ';'". I also checked Array help file and the example as below didn't work at all:

 

To specify a literal array, use curly braces, with the array members separated by commas:
vector[] rgb_array()
{
return { {1, , }, {, 1, }, {, , 1} };
}

 

Here is the simple code I tried to compile, but it returned an error message "Syntax error, unexpected identifier, expecting ';'." :(

 

vector an_array[] = {{1,1,1}, {2,2,2}};
vector a[];

vector[] testFunction(vector[] a){
    return a;
}

a=testFunction[an_array];

 

 

Does anyone know if VEX supports array function? Thank you very much!

Link to comment
Share on other sites

Thanks for your reply, magneto. My codes are in snippet vop inside the attribVOP. For those non-array functions like "vector testFunction(vector a)", they work, but not for "vector[] testFunction(vector[] a)" -_-

Maybe it's VEX that hasn't supported array functions yet :(

Link to comment
Share on other sites

  • 2 years later...

Wrangles (more generally, functions defined inside other functions), still not support returning arrays in Houdini 15.5. Most convenient workaround is modifying an argument.

In code file:

float[] foo()
{
    return array(1, 2, 3, 4, 5);
}

bar = foo();

In wrangle:

void foo(float arr[])
{
    arr = array(1, 2, 3, 4, 5);
}

foo(bar);

 

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

  • 2 years later...

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...