hmihalis1 Posted December 14, 2019 Share Posted December 14, 2019 (edited) Hi, I want to set the value of a parameter based on the value of a switch node, so if switch is 0 set the parameter to 1, if its 1 set the parameter to 10. Could anyone help with this? currently I am trying if((ch("../switch1/input")=0,1,10) could anyone tell me where im going wrong? thanks Edited December 14, 2019 by hmihalis1 Quote Link to comment Share on other sites More sharing options...
flcc Posted December 14, 2019 Share Posted December 14, 2019 is it what you want ? val = ch("../switch1/input") ? 1 : 10; but if you are not comfortable with vex it's more simple and readable to write : if(ch("../switch1/input") == 0){ val = 1; }else{ val = 10; } Quote Link to comment Share on other sites More sharing options...
anim Posted December 14, 2019 Share Posted December 14, 2019 (edited) you have parenteses mismatch, but most importantly you need to use == for equals if(ch("../switch1/input")==0,1,10) also this would work if(ch("../switch1/input"),10,1) Edited December 14, 2019 by anim Quote Link to comment Share on other sites More sharing options...
flcc Posted December 14, 2019 Share Posted December 14, 2019 I've never seen this syntax is this the "ch("../switch1/input") ? 1 : 10;" equivalent in expressions ? Quote Link to comment Share on other sites More sharing options...
hmihalis1 Posted December 14, 2019 Author Share Posted December 14, 2019 Thanks @anim that worked perfectly! Quote Link to comment Share on other sites More sharing options...
anim Posted December 15, 2019 Share Posted December 15, 2019 16 hours ago, flcc said: I've never seen this syntax is this the "ch("../switch1/input") ? 1 : 10;" equivalent in expressions ? Yes, it's hscript, simply different language and therefore different syntax from VEX Quote Link to comment Share on other sites More sharing options...
flcc Posted December 15, 2019 Share Posted December 15, 2019 Ah, so much for me, I was the one who was uncomfortable here. haha Thanks, thomas 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.