DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

finding and replacing single entries in a channel with script

I want to replace all entries below "0" in a channel with the value "0". I´ve tried a For-Loop, but it doesn´t work. For Examble a channel with the Values: -2; -1;0;1;2 should be transfered into 0;0;0;1;2
The code i´ve tried is:
 
For i = 1 To 10
Do
if ChD(i,"Channel 1")<=0 then
ChD(i,"Channel 1")=0
end if
but it doesn´t work.
0 Kudos
Message 1 of 3
(3,099 Views)

Hi

Try this script:

MyChname ="[1]/Test"
for i = 1 to ChnPropValGet(MyChname, "length")
  if ChD(i,MyChname)<=0 then
    ChD(i,ChnPropValGet(MyChname, "number"))=0
  end if
Next

This works for DIAdem 9.0 and later.

Winfried

Message 2 of 3
(3,094 Views)

Hi Johannes

much faster works the a formula:

Call FormulaCalc("Ch(#):=  Ch('Channel 1')*(Ch('Channel 1')>0)")

Hope this helps

Winfried

Message 3 of 3
(3,091 Views)