04-21-2021 09:48 AM
Hey all
I am trying to remove data channels from groups by iterating through a For loop.
This script loads multiple data files at once, and since I don't know how many files will be loaded at a specific time I want this to be a robust process.
Here is the script that I have tried:
for jj = 1 to X
for kk = 1 to noGroups
grName = data.Root.ChannelGroups(kk).Name
if grName = ("CUST"&str(X)) then
Call oElementList.Add(data.Root.ChannelGroups(grName).Channels("SampleTimeCoarse"))
Call oElementList.Add(Data.Root.ChannelGroups(grName).Channels("PacketCounter"))
Call oElementList.Add(Data.Root.ChannelGroups(grName).Channels("Pitch"))
Call oElementList.Add(Data.Root.ChannelGroups(grName).Channels("Roll"))
end if
next
Data.Remove(oElementList)
next
Here is a screengrab of what I want the group to finally look like (CUST) and what it looks like prior to the channels being removed (CUST1 through X):
Thank you for any help and advice!
Solved! Go to Solution.
04-21-2021 10:56 AM
Solved it:
for jj = 1 to X
rmGroup = "CUST"&str(jj) <-- added variable
for kk = 1 to noGroups
grName = data.Root.ChannelGroups(kk).Name
msgboxdisp(grName)
msgboxdisp(rmGroup)
if grName = rmGroup then
Call oElementList.Add(data.Root.ChannelGroups(grName).Channels("SampleTimeCoarse"))
Call oElementList.Add(Data.Root.ChannelGroups(grName).Channels("PacketCounter"))
Call oElementList.Add(Data.Root.ChannelGroups(grName).Channels("Pitch"))
Call oElementList.Add(Data.Root.ChannelGroups(grName).Channels("Roll"))
end if
next
Data.Remove(oElementList)
next