05-31-2012 03:40 PM
How does one, using Diadem Script, set the value of a channel equal to a separate channel property value? I attempt this with the code below. The code below will display the proper value in the message box but will not set the channel equal to that value. Thanks for any help.
dim ROP
ROP = Data.Root.ChannelGroups(4).Channels("Position Regression (ft)").Properties("ResultRegrCoeffB").Value
msgbox (ROP)
Call Calculate("Ch(""[4]/ROP (ft\hr)"")= ROP",NULL,NULL,"")
Call Calculate("Ch(""[4]/ROP (ft\hr)"")=Data.Root.ChannelGroups(4).Channels("Position Regression (ft)").Properties("ResultRegrCoeffB").Value",NULL,NULL,"")
06-01-2012 09:40 AM
Hey atlasengineer -
Try this one line of code:
Data.Root.ChannelGroups(4).Channels("ROP (ft\hr)").Values(1) = Data.Root.ChannelGroups(4).Channels("Position Regression (ft)").Properties("ResultRegrCoeffB").Value
Let me know if this doesn't work.
07-30-2012 03:13 PM
Hi atlasengineer,
I prefer to create intermediate objects and variables and not cram everything onto one line. This way if you need to reference the same variable more than once, such as the Group object, you're not looking it up by name or index each time. Also, and more importantly, if there is an error, you can figure out by the line the error is on which part of the expression is causing trouble:
Set Group = Data.Root.ChannelGroups(4) Set PosChannel = Group.Channels("Position Regression (ft)") PropVal = PosChannel.Properties("ResultRegrCoeffB").Value Set RopChannel = Group.Channels("ROP (ft\hr)") RopChannel.Values(1) = PropVal
Brad Turpin
DIAdem Product Support Engineer
Nationa Instruments