DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Obtaining a scripting ref to a newly created channel

Solved!
Go to solution

I'm a noob to DIAdem scripting and it's been well over a decade since I've done any significant vb coding, so please forgive me for the inane question.

 

I'm using the ChnFiltCalc function to run my data through a low pass filter, and this function automatically creates a new channel containing the filtered signal at the end of the channel group.  In the data portal I'd like to move the new channel so it immediately follows the unfilitered channel it is based on, however, ChnFiltCalc function doesn't a reference to the new channel.  Furthermore, the new channel may or may not use the name I've assigned it (DIAdem will append a number if it is a duplicate name) and based on what I've read in the help files it may not be the element with the largest index.

 

Is there a standard way to robustly obtain a reference to new channels created by functions?

0 Kudos
Message 1 of 4
(5,107 Views)

You can loop through your channels looking for the following property that matches the name you gave the channel

if Data.Root.ChannelGroups(1).Channels(1).Properties("sourceoriginalname").Value = "ABC" then

 

James

0 Kudos
Message 2 of 4
(5,104 Views)
Solution
Accepted by topic author Daklu

Hi Daklu,

 

My personal preference is to first get a channel object variable when you create the target Channel in the Group and in the Channel location (TargetChannelIndex) that you want it to be (where the desired channel name will be unique), then pass that channel object variable to the ANALYSIS command in its target channel parameter.

 

'Set Group = Data.Root.ActiveChannelGroup
'Set Group = Data.Root.ChannelGroups(1)
Set Group = Data.Root.ChannelGroups("DesiredGroupName")
Set RChannel = Group.Channels.Add("Result Channel", DataTypeFloat64, TargetChannelIndex)
Call ChnFiltCalc(XChannel, YChannel, RChannel, ...)

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

 

Message 3 of 4
(5,084 Views)

Thank you both for the responses.  That's exactly what I was looking for.

0 Kudos
Message 4 of 4
(5,071 Views)