Showing results for 
Search instead for 
Did you mean: 

How can I create a new channel by multiplying only same values of one channel for a constant?

Go to solution

Hello guys, I am the newbie of the newbies (not only in DIAdem, but basically for every script-software).


I try to explain my question --> "Channel 1" is composed by 14 numeric values, some of them positive and others negative, but for different reasons I need that Channel 1 would have only positive values or zeros, so all the negative values have to be converted into zeros. The problem is that this operation has to be described into a Script for automatic process, because everytime I load a different "Channel 1" i would only lose time. So, how can write it? Thanks in advance!

0 Kudos
Message 1 of 3
Accepted by topic author Piacioo



If you want to replace all negative values from a channel with 0, you can do this with the ChnRangeLimit method. With the following script all negative values are replaced by 0, because 0 is specified as lower limit. So that no change occurs with the upper limit, NOVALUE is passed.

call ChnRangeLimit("[1]/Channel1", 0, NOVALUE, "[1]/Channel1_MinZero")


If you want to do this only for specific channels, then add a condition, such as querying the channel name or checking for the minimum of the channel. The example code shows how to check the mininum of each channel of the second group. You can test it with Example.tdm.


dim group : set group = data.Root.ChannelGroups(2)
dim result_group : set result_group = data.Root.ChannelGroups.Add("ResultGroup")
dim chn

for each chn in group.Channels
  if chn.Minimum < 0 then
    call ChnRangeLimit(chn, 0, NOVALUE, result_group.Name & "/" & chn.Name & "_MinZero")
  end if


0 Kudos
Message 2 of 3

It works!!! Thank you!

0 Kudos
Message 3 of 3