DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Creating a Script for Calculator

Hello Everyone,

I am trying to write a script to ease some of the more tedious work I do when I process data files.  The biggest need I have right now is a script that will perform a series of calculations on data once it is loaded in the portal. 

For instance, the script would simply run through equations such as these:

Ch('Channel 1 Eng') := 34.093*Ch('Channel 1')-169.46
Ch('Channel 2 Eng') := 32.093*Ch('Channel 2')-160.46
.....

Is there an easy way to do this?  I'm not too familiar with scripting, and I'd rather just do this by hand if it's going to take a long time to learn how to do this right now. 

Thanks for the help!
 
0 Kudos
Message 1 of 4
(3,984 Views)

Hello AlexP1!

A script is the right thing for you and not to difficult. Try the 'Teach in' mode in the SCRIPT device. Once started you can proceed as normal with your calculations. All steps will be recorded and you can edit the result as you like.

Matthias

Matthias Alleweldt
Project Engineer / Projektingenieur
Twigeater?  
0 Kudos
Message 2 of 4
(3,979 Views)

Hi Alex,

By "Teach-In", Twigeater means the VBScript Recorder, which you can turn on in the SCRIPT panel, and I heartily endorse this suggestion.  What you will get when you do this is a series of commands like the following:

DIAdem 10.2 or later
Call ChnCalculate("Ch(""Channel 1 Eng"") = 34.093*Ch(""Channel 1"")-169.46")
Call ChnCalculate("Ch(""Channel 2 Eng"") = 32.093*Ch(""Channel 2"")-160.46")
.....

DIAdem 10.1 or earlier
Call FormulaCalc("Ch('Channel 1 Eng') := 34.093*Ch('Channel 1')-169.46")
Call FormulaCalc("Ch('Channel 2 Eng') := 32.093*Ch('Channel 2')-160.46")
.....

Note that the "FormulaCalc" commmands will work in DIAdem 10.2 and later as well, and for large channels these will actually run faster than the "ChnCalculate" commands.  The advantage of the "ChnCalculate" commands is that they can contain all VBScript functions and operate on string channels, neither of which the "FormulaCalc" commands can do.

Brad Turpin
DIAdem Product Support Engineer
National Instruments

0 Kudos
Message 3 of 4
(3,957 Views)
That's perfect!  Exactly what I was looking for.  Thanks so much!
0 Kudos
Message 4 of 4
(3,934 Views)