ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

ChnCalculate conditional

Solved!
Go to solution

Hello to everyone!!

 I need to use following statement:  

 

ChnCalculate("Ch(""[1]/"Channel1""") = Round(Ch(""[1]/"Channel1"""),(cint(log(abs(Ch(""[1]/Channel1""))))-2))")

 

The rounding of values have this particular condition. As you see to calculate decimal places I use a "log". My problem is that when my channel value is equal to "0" the returned value of course is No Value. I don't know if is possible to only perform the ChnCalculate when the value in the channels is different from 0. Or I have to program my script differently.

 

Thanks to everyone!

0 Kudos
Message 1 of 2
(4,051 Views)
Solution
Accepted by topic author MariaEsmeral

Hello MariaEsmeral,

 

I fit is necessary for you to have a rounding with a dynamic number of digits then my suggestion is to add a NoValue function to your script. As you mentioned in case of zero the ChnCalculate function returnes for the log a NoValue. But in case of zero a rounding would return zero. So after the calculation with ChnCalculate you can set all NoValues to zero with this command:

 

Call ChnNovHandle("[1]/Channel1","[1]/Channel1","SetValue","XY",1,1,0)

 

You find the NoValue handling function in ANALYSIS in the toolbar “Channel functions”

 

Greetings

Walter

Message 2 of 2
(4,035 Views)