Evaluate Function

Recommended Posts


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









Link to comment
Share on other sites

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

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])")




Link to comment
Share on other sites

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!!





Link to comment
Share on other sites


This topic is now archived and is closed to further replies.