From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

DIADEM SCRIPT: how do I assign a channel contents to a variable so I can pass to a function.

I need to be able to assign a single channel to a variable in a DIADEM script so that I can pass the channel contents to a function which will calculate the definite integral of a section of the data. The two X coordinates for calculating the integral and the integration time will be passed to the function as arguments.

 

Also, is it possible to use the local variable for the channel created inside the function when it is called in a way similar to an array by specifying and index after the local variable name or must I use  the CHD command to access the value of elements?

0 Kudos
Message 1 of 3
(6,131 Views)

Hi Disco,

 

I recommend you use channel objects to pass the channel reference to the subroutine-- this is faster and easier and has the further advantage of offering you built-in access to the values array of that channel.

 

'Set Group = Data.Root.ActiveChannelGroup
'Set Group = Data.Root.ChannelGroups(1)
Set Group = Data.Root.ChannelGroups("GroupName")
Set XChannel = Group.Channels(1)
Set YChannel = Group.Channels("ChannelName")
Set RChannel = Group.Channels("NewIntegral")
Call RunAnalysis(XChannel, YChannel, RChannel)
MsgBox "First Integral Value = " & RChannel.Values(1)
Sub RunAnalysis(XChannel, YChannel) Call ChnIntegrate(XChannel, YChannel, RChannel) End Sub ' RunAnalysis()

Brad Turpin

DIAdem Product Support Engineer

National Instruments

 

0 Kudos
Message 2 of 3
(6,112 Views)

Works great. Many thanks!

0 Kudos
Message 3 of 3
(6,096 Views)