04-10-2014 05:49 AM
The LIN/LIN_Error channel has 3000 values in it. I want to add a correction value to each of the 3000 values in it.
If I use a constant it works ok. For example:
Call ChnCalculate (" Ch(""LIN/LIN_Error"") = ( 2 + Ch(""LIN/LIN_Error"" ) )" ) adds 2 to each value.
However if I try this with a variable it doesn't work.
Dim Corr
GlobalDim "Corr"
Corr = 2
Call ChnCalculate (" Ch(""LIN/LIN_Error"") = ( Corr + Ch(""LIN/LIN_Error"" ) )" )
Solved! Go to Solution.
04-10-2014 02:23 PM
Hi Frank,
The problem is your first line. By executing "Dim Corr" in the VBScript, you force that variable name to reference the VBScript variable and not the DIAdem global variable-- the color highlighting in the SCRIPT panel does not reflect this, which is confusing. If you remove the Dim Corr statement, then the VBScript will correctly reference the global variable. Another way of putting this is that your VBScript never sets the global Corr variable to 2. The ChnCalculate() command correctly references the global Corr variable, but it is still set to 0.
However, for this task I would recommend instead the ChnLinScale() function, which is simpler, will execute faster, accepts regular VBScript variables, and therefore bypasses all of this confusion.
Dim Corr Corr = 20 Call ChnLinScale("LIN/LIN_Error", "LIN/LIN_Error", 1, Corr)
Brad Turpin
DIAdem Product Support Engineer
National Instruments
04-10-2014 05:36 PM
This solved the problem. Both solutions worked and I went with your recommendation of ChnLinScale.
Thank you