bolegna Posted August 13, 2020 Share Posted August 13, 2020 Hello ODF, Thanks for all the help, this is a great site for looking up things but i have to dip my toe in and ask a simple question: I'm having trouble with an expression inside a switch node, i want to change the switch from one input to another based on detail I've created from a filename I'm a complete novice when it comes to expressions, would someone steer me right here? Thanks in advance! Quote Link to comment Share on other sites More sharing options...
ikoon Posted August 13, 2020 Share Posted August 13, 2020 Hi Rodger, I am not sure if you can compare two strings in the expression. Even if you try it without the details, "M"=="M" errors. We have this function to compare strings: https://www.sidefx.com/docs/houdini/expressions/strcmp.html Try something like this: if(strcmp(details( ),"M"),1,0) Quote Link to comment Share on other sites More sharing options...
underscoreus Posted August 15, 2020 Share Posted August 15, 2020 Another way you could do it which is the way I usually deal with it when I use expressions like this in a switch node is that I just use vex to make sure that the attribute I am looking up is a number and then just look up the number attribute with the switch. So essentially just put a wrangle down where you do the whole if(s@gender == "M") { i@switch_num = 0; } else if(s@gender == "F") { i@switch_num = 1; } And then in your switch just do: detail("/path/to/node", "switch_num", 0) 2 Quote Link to comment Share on other sites More sharing options...
bolegna Posted August 25, 2020 Author Share Posted August 25, 2020 Amazingly simple - that's exactly what i was looking for @underscoreus! Thank you very much : ) 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.