DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Removing quotation marks from channel names

Solved!
Go to solution

Firstly - I am new to both DIAdem and VB so please forgive my ignorance!

 

I have a large data set containg many groups with (almost) identical channel names in each group. For reasons not worth going into some of the channel names have quoation marks around them, while others do not.

 

I am trying to remove the quoation marks to make all channel names consistent throughout the groups, for this I was hoping to loop through the groups renaming channels as appropriate

 

I think this should work:-

 

For

 i = 1 to GROUPCOUNT

Call GROUPDEFAULTSET(i)

 CN(""ChannelName"")="ChannelName"

Next

 

Where ChannelName is the name I am trying to replace, But I get the following error:- Expected ')'

Can anyone point out where I am going wrong?

 

(Note - I also tried using triple quotation marks ("""ChannelName"""), but I get this error instead - CN(""ChannelName""):=ChannelName Close bracket ")" expected for field index)

 

For bonus points - how to I get the loop to skip over any groups where the channel I am referencing already doesn't have quotation marks in it, rather than giving me an error that the channel can't be found?

 

Many thanks in advance for any assistance!

 

Dan

 

 

 

 

0 Kudos
Message 1 of 3
(4,705 Views)
Solution
Accepted by DBUK

Hello Dan,

 

You are using an old script syntax to manipulate the data. Please find below the current way to replace quotation marks with an underscote:

 

dim iLoopG, iLoopC, oGroup, oGroupChns, sQM

sQM = chr(34) ' the " character

set oGroup = Data.Root.ChannelGroups

for iLoopG = 1 to oGroup.Count
  set oGroupChns = oGroup(iLoopG).Channels
  for iLoopC = 1 to oGroupChns.Count
    'msgbox oGroupChns(iLoopC).Name
    oGroupChns(iLoopC).Name = Replace(oGroupChns(iLoopC).Name, sQM, "_")
  next
next

Greetings

Walter

Message 2 of 3
(4,690 Views)

Hi Walter,

 

That works perfectly, many thanks for your help!

 

Dan

0 Kudos
Message 3 of 3
(4,683 Views)