DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

channel reference in formulacalc

Hi, I am trying to select channels using ChnGet which provides me with ChnNo1, ChnNo2, etc. and use the selected channels in FormulaCalc.  I am guessing I am just having some problems with syntax.  Below is a sample of the code I am trying to run which does not work.  Is there and easy way to do this?

Call Chnget (3,0,channels)
Call FormulaCalc("ch('test') := 2 * ChnNo1 + ChnNo2")

Thanks, Tom
0 Kudos
Message 1 of 4
(3,409 Views)
I think I figured it out.

It appears to work if I use:

Call Chnget (3,0,channels)
Call FormulaCalc("ch('test') := 2 * ch(ChnNo1) + ch(ChnNo2)")

Any explanation for the rule or general syntax for formulacalc would still be appreciated.

Tom
0 Kudos
Message 2 of 4
(3,400 Views)

Hi Tom,

The ChnNo1 variable is an integer variable that stores a channel number.  The FormulaCalculator will understand channel name references if they are set off by quotes (Ch('test'):= 'New' + 'Old'), but when using channel numbers the Ch() syntax is required to distinguish the integer referring to a vector (channel) from the integer referring to a simple constant.

I go ahead and always use the Ch() syntax everywhere just to keep things simple and consistent.

Brad Turpin
DIAdem Product Support engineer
National Instruments

0 Kudos
Message 3 of 4
(3,391 Views)
Thanks.

Tom
0 Kudos
Message 4 of 4
(3,385 Views)