Rodney Posted September 5, 2017 Share Posted September 5, 2017 Hi I am trying to use the evaluate function for a set channel for a rocker switch I can get the evaluate function to work with a variable - see screenshot evaluate1 (Sites[Site_ID[0]] = "CB") I can set the channel per screenshot 2 and the variable in screenshot 1 toggles as expected What I would like to do in screen shot 2 is use evaluate(Sites[Site_ID[0]] + "_relay1") so it returns "cb_relay1" and sets the channel (or any other channel depending on the value of Sites[Site_ID[0]]) I can't seem to get the syntax correct - that's if what I am trying to do is possible of course again your help most appreciated Rodney Link to comment Share on other sites More sharing options...
AzeoTech Posted September 5, 2017 Share Posted September 5, 2017 I'm confused. You are trying to set the channel using evaluate()? You can't do that, any more than you can set sin(x) to 1 and expect x to become 1.57. I understand what you are thinking, but computer compilers just don't work that way. If you want the switch to change something different you'll need to either use script to change the strSetChannel variable on the button, or you'll need to use objects, which is probably the better way to handle what you are doing since you appear from all your posts to be trying to do the same thing with selecting a site in lots of places. But doing so requires a bit more scripting, so you might want to stick with just updating the components to set the correct variable. Link to comment Share on other sites More sharing options...
SteveMyres Posted September 5, 2017 Share Posted September 5, 2017 How about driving a local channel using the switch, then use evaluate() or execute() in the channel event? That's what I did here and I think it's doing what you're after. I used = rather than AddValue so it will work with any target variable, not just channels. TargetChannel contains "Ch2". This is in the Ch1 event execute(TargetChannel + " = (Ch1[0])") Rocker.ctl Link to comment Share on other sites More sharing options...
SteveMyres Posted September 5, 2017 Share Posted September 5, 2017 Oh, just read your reply. I was looking for a destination channel string in the rocker switch, but it didn't show in the properties table, so I wasn't sure it was accessible (or what it would be called). Link to comment Share on other sites More sharing options...
Rodney Posted September 7, 2017 Author Share Posted September 7, 2017 Thanks - I had an inkling it was impossible!! I have used the strSetChannel variable as suggested and achieved what I wanted to do - set the channel based on the site selected Regards Rodney Link to comment Share on other sites More sharing options...
Rodney Posted September 7, 2017 Author Share Posted September 7, 2017 Thanks Steve I am new to DAQ and not a programmer (an accountant actually) - my scripting skills are based on an elective - BASIC programming - I did 35 years ago at University..... any replies I get from other forum members gratefully accepted!! Regards Rodney Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.