DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Deleting multiple channels with wildcards

Solved!
Go to solution

Can antbody help..?

I'm trying to create a small routine to delete channles beginning with "T_" and using the * wildcard .

I've tried copying similar examples from the forum but can't seeem to get it to work..

 

Dim Group, Channels, DataChannel, i
Set Group = Data.Root.ChannelGroups(1)
Set Channels(i)= Data.GetChannels("T_*")
FOR i = 1 TO Channels.Count
Data.Root.ChannelGroups(1).Channels.Remove
NEXT ' i

0 Kudos
Message 1 of 8
(5,545 Views)
Solution
Accepted by topic author adek

Hey Adek, 

 

Check it out, 

 

Dim oGr, oChn, DataChannel, i


Set oGr = Data.Root.ChannelGroups(1)
Set oChn= Data.GetChannels(""&oGr.Name&"/T_*")
For i=1 to oChn.Count
      Call oGr.Channels.Remove(oChn.Item(i).Name)
Next

 

i assumed that you only want to delete channels in the "first" group. Otherwise just include an additional loop to sweep all your groups

 

Regards,

 

Javier

 

0 Kudos
Message 2 of 8
(5,538 Views)

Hey Guys,

 

The GetChannels() method doesn't need to have Group information, so if you want to wildcard just the channel name "T_*", you can do this:

 

Set Channels = Data.GetChannels("T_*")
For Each Channel In Channels
  Msg = Msg & Channel.ChannelGroup.Name & "/" & Channel.Name & vbCRLF
Next
MsgBox Msg

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 3 of 8
(5,524 Views)

Thank you javier,

Very helpful.

0 Kudos
Message 4 of 8
(5,508 Views)

Hi Brad,

Script now modified.

Regards

Adrian

0 Kudos
Message 5 of 8
(5,507 Views)

Hi everyone,

 

I write here to ask for a little help, I am trying to count the number of grupos from a test which name end with "A", I tried to use "*" wildcart to do so, but as i run the script it never count anything as if there where no any group name ending with "A" and I know that there are a lot. Do you know why Wildcarts are not working here?

 

Thank You

(the script I am using is here)

 

nBA =0

For i = 1to nGroups

 

If Data.Root.ChannelGroups(i).Name = ("*A") then

nBA = nBA +1

MsgBox (nBA)

 

EndIf

Next

 

0 Kudos
Message 6 of 8
(4,902 Views)

Hi marispailis

 

you have to use the string functions to search for goupnames

 

Dim Group
For Each Group in Data.Root.ChannelGroups
  If lcase(Right(Group.Name,1)) = "a" then
   call msgbox (Group.Name)
  End if
Next

 Hope this helps

 

Winfried

0 Kudos
Message 7 of 8
(4,898 Views)

Very Helpfull! Thank you so much 😃

0 Kudos
Message 8 of 8
(4,894 Views)