DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Storing Group Names to a Single Text Channel

Solved!
Go to solution

Hi,

 

I'm using DIAdem 2017.  I have a TDM file containing 10 groups of data, each with a unique text name.  After creating a new Group and Channel called "Results" and "Max Displacement", my script will loop through each group, do a calculation, and then store the value into the next row of the "Max Displacement" channel for a total of 10 rows when complete.

 

Under the "Results" group, I'd like to also create a second channel of text that captures the group name each time the script loops from group to group.  However, I'm having trouble finding a command that will store text to a string channel.

 

Here is a simplified version of the script (using only 3 groups) and the error I am receiving.  I'm guessing I need a different command other than "ChnGenVal" to add strings to each row of this channel, but I cannot seem to find something that will work.

 

'Create 3 generic groups
Call Data.Root.ChannelGroups.Add("Test A", 1).Activate()
Call Data.Root.ChannelGroups.Add("Test B", 2).Activate()
Call Data.Root.ChannelGroups.Add("Test C", 3).Activate()

 

'Create group called "Results" and channel called "Names"
Call Data.Root.ChannelGroups.Add("Results", 4).Activate()
Call Data.Root.ChannelGroups("Results").Channels.Add("Names",DataTypeString,1)

 

'Extract name of each group and assign to "Name" channel
Dim a,b
a = 1
Do While (a < 4)
b = Data.Root.ChannelGroups(a).Name
Call ChnGenVal("Results/Names",a,1,b,0,0)
a = a + 1
Loop

 

0 Kudos
Message 1 of 4
(3,075 Views)
Solution
Accepted by topic author DJ324911
Data.Root.ChannelGroups("Results").Channels("Names").Values(Data.Root.ChannelGroups("Results").Channels("Names").Size + 1) = Data.Root.ChannelGroups(a).Name
Message 2 of 4
(3,059 Views)

Awesome!  Thank you very much for the quick reply!  The solution worked, although I did have to modify it slightly as follows:

 

Data.Root.ChannelGroups("Results").Channels("Data_Set").Values(Data.Root.ChannelGroups("Results").Channels("Data_Set").Size + 1) = Data.Root.ChannelGroups(a).Name

Message 3 of 4
(3,023 Views)

Please disregard my change.  The original answer from gsklyr was correct.

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