Jump to content

Define a function in point wrangle


Recommended Posts

13 minutes ago, AntoineSfx said:

So this was an error (; instead of ,) but I still can't get this to compile, because of the array type as return type:


int [] myfunc(int input; int ptnum)
{ int  result[];
   return result;
}

 

not sure that vex allows return array

Link to comment
Share on other sites

On 27/01/2018 at 8:39 AM, julian johnson said:

function int[] test()
{
        int result[] = {1,2,3};
        return result;
};

i[]@test = test();

I get syntax errors using the 'normal' array syntax in the documentation i.e. a simple int[] test(){}; but if you disambiguate using the 'function' syntax it seems to work..

This solves my problem. May I ask where you have found this ? Is there a BNF for VEX ?

Edited by AntoineSfx
Link to comment
Share on other sites

3 hours ago, julian johnson said:

I found this in the documentation:

http://www.sidefx.com/docs/houdini/vex/arrays.html

Not sure what a BNR is :-)

ok. Typo.. I meant BNF, the formal definition of the language (Backus normal form)

Also, the use case of the keyword function is for nested functions.

So I assume the whole VEX block is really run inside a parallel for loop over prim / points ..

Edited by AntoineSfx
Link to comment
Share on other sites

//
// VEX Code Generated by Houdini 16.5.268
// Date: Sun Jan 28 16:23:25 2018
// File: C:/Users/johnson/untitled
// Node: /obj/geo1/attribwrangle2/attribvop1
//

#ifndef VOP_OP
#define VOP_OP
#endif
#ifndef VOP_CVEX
#define VOP_CVEX
#endif

#pragma opname attribvop1
#pragma oplabel "Local Vop Code"
#pragma opmininputs 1
#pragma opmaxinputs 1


#include <math.h>
void 
_obj_geo1_attribwrangle2_attribvop1_snippet1(int _bound_test[])
{
    
    function int[] test()
    {
            int result[] = {1,2,3};
            return result;
    };
    
    _bound_test = test();
    
}

cvex
obj_geo1_attribwrangle2_attribvop1(export int test[] = {})
{
    
    // Code produced by: snippet1
    _obj_geo1_attribwrangle2_attribvop1_snippet1(test);
}

 

Looks like a nested function when you expand the inner VOP node to VEX...

 

Link to comment
Share on other sites

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