10-24-2008 02:02 AM
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
Solved! Go to Solution.
10-24-2008 09:29 AM
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
10-27-2008 01:39 AM
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.
10-27-2008 03:12 AM
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?
10-27-2008 09:37 AM
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
10-28-2008 02:20 AM
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.
10-28-2008 02:26 AM
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.