sortofsleepy Posted May 18, 2021 Share Posted May 18, 2021 (edited) Hey everybody, a bit of a Houdini beginner still and I figured I'd try here for some help since this issue has been gnawing away at me the past couple of days ha. I am trying to port something from Javascript over to Vex at the moment and have been running into issues. I'm almost got things figured out but am having trouble with what is hopefully the last issue. This is basically the code I'm trying to make work at the moment. int count = 0; float radius = 0.01; float growth = 0.01; float max = 0.5; while(radius < max && count < 20){ radius += growth; count++; } // do something with radius afterwards The issue I am finding is that the "&&" operator appears to act like a "||" operator and things are terminating when the "count<20" portion is reached instead of waiting until both statements are done. In this example, the radius variable will end up only increasing to .21 instead of .5-ish since count will finish first. Is there something I'm doing wrong here? Node Details ===== Wrangle is set to guess group type and run over setting is set to "Detail" Not sure if this would help but code above is just from a test node; node I'm trying to write to has 5 points coming into the first slot from a scatter node. Thank you! Edited May 18, 2021 by sortofsleepy Quote Link to comment Share on other sites More sharing options...
sortofsleepy Posted May 18, 2021 Author Share Posted May 18, 2021 (edited) Ah.. I might have written this prematurely after examining the Javascript in more detail - please ignore this for now. Edited May 18, 2021 by sortofsleepy Quote Link to comment Share on other sites More sharing options...
acey195 Posted May 21, 2021 Share Posted May 21, 2021 (edited) (just in case it helps anyone else) Not completely sure, but I think the problem you were having, were the extra spaces in your while condition without brackets, sometimes it does "connect" the operators in unexpected ways. so while(radius < max && count < 20){ might behave differently than: while((radius < max) && (count < 20)){ or while(radius<max && count<20){ (last 2 should behave the same) Edited May 21, 2021 by acey195 2 Quote Link to comment Share on other sites More sharing options...
Skybar Posted May 21, 2021 Share Posted May 21, 2021 In this case, wouldn't you actually want || ? If you have 1 && 1 it will loop, but if one of them changes it will stop - 1 && 0. But with 1 || 0 it will still continue if either one of them is still true, so it will "wait" until both are false, 1 || 1 = true, 1 || 0 = true, 0 || 0 = false. 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.