DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

how to include a variable in a formula calc

Solved!
Go to solution

Hi,

 

I need to do some calc formula to help my report but I encounter a problem.

 

I use this formula to erase some data from my channel but the formula don't reconize my variables.

 

R4 = CMax(Ch("[1]/TRAVEL_DISTANCE"))

Call DataBlDel("[1]/TRAVEL_DISTANCE_SMT",ChnFind("Ch(""[1]/TRAVEL_DISTANCE"")>R4",1),2000,1)'... ChnNoStr,ChnRow,ValNo,ValDelOnly , but the formula for the ChnRow don't see the variable R4, and if I put " before R4( to make R4 green) I receive an error : Expected ')'.

Please tell me how I can use a variable in a formula , so the formula can see it.

 

Thanks

0 Kudos
Message 1 of 7
(5,116 Views)

Hi Marse,

 

You were missing a couple of parentheses.  It's much easier to debug if you break up the expression into its components and then add the resulting parameter (Row) into the final function (DataBlDel):

 

R4 = CMax(Ch("[1]/TRAVEL_DISTANCE"))

Row = ChnFind("Ch(""[1]/TRAVEL_DISTANCE"")>R4", 1)

Call DataBlDel("[1]/TRAVEL_DISTANCE_SMT", Row, 2000, 1)

 

Brad Turpin
DIAdem Product Support Engineer
National Instruments

0 Kudos
Message 2 of 7
(5,104 Views)

Hi Brad,

 

I try in your way but it still not working, the problem is with the formula for the Row parameter, it takes the 0 value, and int the "Call DataBlDel" statement I have 0 value to the Row, and I receive the error from the attachament.

I thing the problem is because the formula don't see the R4 variable, and like I said to you if I put (") before R4, Diadem tell me : Expected ')'.

 

Please tell me how can I make R4 visible in the  Row formula.

 

Thank you  for your time.

0 Kudos
Message 3 of 7
(5,088 Views)

Hi Marse,

imo there is a logical mistake.

You are looking for the maximum of a channel (R4).

Then you are looking for a value which is bigger (>) than R4 in the same channel.

It's impossible, insn't it?

 

greets Andreas

Volkswagen AG
Wolfsburg - Germany
0 Kudos
Message 4 of 7
(5,084 Views)
Solution
Accepted by Marse

Hi marse,

 

The smiley face inserted by the text editor got in our way.  If you replace the smiley face in my reply with a "close-parenthesis" character, then the code will run correctly.  I have to admit, though, that there does appear to be a logic error, despite the fact that the code ran correctly on the data set I tried it with.  But finding the row of the peak is something you can do less ambiguously and more easily with the PNo() function:

 

R4 = CMax(Ch("[1]/TRAVEL_DISTANCE"))

Row = PNo("[1]/TRAVEL_DISTANCE", R4)

Call DataBlDel("[1]/TRAVEL_DISTANCE_SMT", Row, 2000, 1)

 

Brad Turpin
DIAdem Product Support Engineer
National Instruments

0 Kudos
Message 5 of 7
(5,076 Views)

Thank you Brad, it help me. Now it works fine.

 

I realize that the smiley face means a "close parenthesis", but it still not works in that way.

 

Thank you again for the advise with PNo, now it is ok.

0 Kudos
Message 6 of 7
(5,057 Views)

Hi Hass,

 

Now that you tell me it has sens.

Now it is logic why the formula didn't work.

 

Thank you for your time.

0 Kudos
Message 7 of 7
(5,055 Views)