DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

ChnFind using ValEqual

Solved!
Go to solution

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

Download All
0 Kudos
Message 1 of 7
(2,565 Views)

Getting rid of the Str() did it for me.  Didn't need the 

Call ChnCharacterAll()

even 

0 Kudos
Message 2 of 7
(2,481 Views)

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.

0 Kudos
Message 3 of 7
(2,466 Views)

I also thought about whether the load behavior plays a role and set ImportAction = "LoadImmediately". Doesn't make any difference either.

0 Kudos
Message 4 of 7
(2,458 Views)
Solution
Accepted by topic author gefluegelschere_

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

Message 5 of 7
(2,434 Views)

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

0 Kudos
Message 6 of 7
(2,412 Views)

Here are examples on using all of the DIAdem event detection commands:  http://www.savvydiademsolutions.com/analysis.php?topic=analysis-channel-event-detection-commands

 

 

0 Kudos
Message 7 of 7
(2,374 Views)