NI Home
Cart Cart | Help
Hello Events Academic NI Developer Zone Support Solutions Products & Services Contact NI MyNI
You are here: 
NI Home > NI Developer Zone > NI Discussion Forums


Reply
Member
atlasengineer
Posts: 23
0 Kudos

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

 



Active Participant
DRock
Posts: 244
0 Kudos

Re: Make a channel value equal to a channel property

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
Trusted Enthusiast
Brad_Turpin
Posts: 2,367
0 Kudos

Re: Make a channel value equal to a channel property

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

By using this web site, you accept the Terms of Use for this web site. Please read these Terms of Use carefully before using any part of this site. Please go here for information on ni.com's copyright infringement policy.
My Profile | Privacy | Legal | Contact NI © 2011 National Instruments Corporation. All rights reserved.    |    E-Mail this Page E-Mail this Page