DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Make a channel value equal to a channel property

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

 

0 Kudos
Message 1 of 3
(4,595 Views)

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.

Derrick S.
Product Manager
NI DIAdem
National Instruments
0 Kudos
Message 2 of 3
(4,569 Views)

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

0 Kudos
Message 3 of 3
(4,468 Views)