01-17-2019 02:15 PM
Hello,
I'm trying to find the first index where my accelerometer goes below -1G. I'm trying to use the Find function to do this, and having some syntax errors.
My code looks like this:
index = Find("Ch(""accelChannel"")<-1")
accelChannel is a variable that contains the name string of my data channel. I'm writing this script with the assumption that I won't know the name or index of the channel in my data structure. I have a dialog box that the user selects the channel and sets the accelChannel variable.
I'm trying to pass this string to the Find function to do the search, and I can't get it to work. Is it possible to pass a variable to the Find function?
Solved! Go to Solution.
01-18-2019 01:20 AM
You can just create a string by resolving the value.
index = Find("Ch(""" & accelChannel & """)<-1")
01-18-2019 06:30 AM
That worked, Thanks!
02-19-2019 04:18 PM - edited 02-19-2019 04:21 PM
Hi sirwin,
I find putting the channel name with """ quotes into the formula makes it hard for me to debug when the formula gets a little more complicated. The following approach will work in all DIAdem versions:
T1 = "accelChannel" index = Find("Ch(T1)<-1")
And this nicer, object-oriented approach will work in recent DIAdem versions:
Set DataChannel = Data.GetChannel("accelChannel") Channels = Array(DataChannel) Symbols = Array("Accel") index = ChnFind("Accel<-1", 1, Symbols, Channels)
It's much better for debugging if the "accelChannel" channel reference fails outside the Find function.
Brad Turpin
DIAdem Product Support Engineer
National Instruments