01-04-2018 09:12 AM
Hello
I would like to create an IF condition for a string at the beginning of the description.
For ex.
If the "N.A." string exist at the beginning of channel Description (Description for ex. "N.A. Lap Belt L.C. LHS") then to delete the channel.
I tried the following without success:
Option Explicit 'Forces the explicit declaration of all the variables in a script.
Dim i, j, oMyChn, oMyUnit
For i = 1 to GroupCount
For j = 1 to GroupChnCount(i)
if(Data.Root.ChannelGroups(i).Channels(j).Properties("description").Value="N.A.") THEN
Call Data.Root.ChannelGroups(i).Channels.Remove(j)
end if
Next
Next
I will appriciate your assistance solving this issue.
Oded
01-04-2018 09:36 AM
Hi odedmi,
The description is not identical with "N.A." but is only a part of it.
Instead of:
if(Data.Root.ChannelGroups(i).Channels(j).Properties("description").Value="N.A.") THEN
you should use:
If InStr(1, Data.Root.ChannelGroups(i).Channels(j).Properties("description").Value,"N.A.",VBTextCompare) = 1 Then
Please have a look in the help: http://zone.ni.com/reference/en-XX/help/370858N-01/vbs/methods/vbs_method_instr_globalobj/
Winfried
01-05-2018 11:33 AM
Hello Odedmi,
if you are looking for a more compact solution and you are using a recent version of DIAdem, take a look at data.getchannels
If you use this function in conjunction with data.remove you can do something like:
Dim oList
Set oList = Data.GetChannels("N.A.*")
If ( 0 < oList.Count ) Then Call Data.Remove(oList)
If you are 100% sure the channels exist (at least one) you can go as compact as
Call Data.Remove(Data.GetChannels("N.A.*"))
but that would give you an error message in case no channel name starting with "N.A." exists
01-31-2018 02:22 PM
Hi All,
Please note that Data.GetChannels(CompareString) only operates on the name of the Channel and the name of the Group that Channel is in. This would not be the right approach to use if the CompareString in question is stored in a Channel or Group property other than the name, such as the "Description" property.
Cheers,
Brad Turpin
DIAdem Product Support Engineer
National Instruments