10-09-2014 06:22 AM
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?
10-09-2014 11:11 AM
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
10-10-2014 03:16 AM
Works great. Many thanks!