09-30-2019 01:49 AM
Hello DIAdem enthusiasts,
I'm currently faxinga somewhat strange problem. I'm trying to find the index of the channel minimum with ChnFind(ValEqual(...)). The value in this special case is -0.0001910030841827 (very close to 0).
The return value of
Call ChnCharacterAll() Call MsgBox(ChnFindReverse("ValEqual(Ch(""[1]/Chn0""), " & Str(Data.Root.ChannelGroups(1).Channels("Chn0").Properties("minimum").Value) & ")"))
is 0 and not 231 as expected.
but the return value of the function is unfortunately 0 and not 231. If I manipulate the value in the VIEW manually and then use the old value again (e.g. -0.0001910030841827 --> -0.0001910030841827 --> -0.0001910030841827), the function finds the correct index (231).
Thomas
Solved! Go to Solution.
09-30-2019 05:11 PM
Getting rid of the Str() did it for me. Didn't need the
Call ChnCharacterAll()
even
10-01-2019 12:56 AM
Removing the Str()
Call MsgBox(ChnFind("ValEqual(Ch(""[1]/Chn0""), " & Data.Root.ChannelGroups(1).Channels("Chn0").Properties("minimum").Value & ")"))
doesn't work for me. The result remains 0. This would also not comply with the syntax of ChnFind (FormulaTxt, string). You really don't need the ChnCharacterAll, I only used it because I copied the values of the channel from another file.
I'vew tried this with DIAdem 2017 SP1 64 bit and 2018 SP1 64 bit.
10-01-2019 01:11 AM
I also thought about whether the load behavior plays a role and set ImportAction = "LoadImmediately". Doesn't make any difference either.
10-01-2019 02:55 PM - edited 10-01-2019 02:56 PM
Hi gefluegelschere,
I strongly recommend you break up the content of any Calculate() or ChnFind() expression to make debugging simpler. In this case the "&" operator casts the result to a string. If instead you assign the minimum property directly to a double-precision global variable, such as R1, then you can use that variable's name directly in the expression, sidestepping the string conversion and making the code more readable and easier to debug.
R1 = Data.Root.ChannelGroups(1).Channels("Chn0").Properties("minimum").Value L1 = ChnFind("ValEqual(Ch(""[1]/Chn0""), R1)") MsgBox L1
Brad Turpin
DIAdem Product Support Engineer
National Instruments
10-02-2019 05:13 AM
Hi, Brad,
that actually solves the problem, thank you very much. Now only the question remains, why for example ChnFind("ValEqual(Ch("""[1]/Chn0"""), -0.0001910030841827)") does not work.
Thomas
10-07-2019 10:03 AM
Here are examples on using all of the DIAdem event detection commands: http://www.savvydiademsolutions.com/analysis.php?topic=analysis-channel-event-detection-commands