MJNorris Posted August 2, 2018 Share Posted August 2, 2018 Hi there, I'm trying to wrap my head around custom vex functions, mainly from a theoretical point at this stage so not really addressing a specific use, just general knowledge. When I create a VEX function I believe that I have to specify exactly what type of data it is expecting from the arguments and exactly what type of data it will return. eg. function int my_function(float a){ return int(a); } in which case I have to feed it an INT argument and it will always return an INT value. My question is this, is there any way of creating a VEX function which can accept multiple arguments, but not fail if one or more of those arguments are absent when the function is called? Or better yet a way of taking a single argument with out specifying what type of data that argument should be? I'm guessing that this is somehow possible as most of the existing Houdini VEX functions work with multiple flavours of input. Thanks in advance. M Quote Link to comment Share on other sites More sharing options...
3dome Posted August 2, 2018 Share Posted August 2, 2018 it's called function overloading. for details see http://www.sidefx.com/docs/houdini/vex/lang.html#functions this is a quick basic example where VEX determines which function to use based on the argument types you feed to the function int func(int a; float b){ return int(a*b); } float func(float a; float b){ return a*b; } printf("value is %d", func(2.0, 2.75)); //change the 2.0 to 2 to see the difference 2 Quote Link to comment Share on other sites More sharing options...
MJNorris Posted August 2, 2018 Author Share Posted August 2, 2018 Fantastic, this is exactly what I was after! Many Thanks 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.