From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I determine if a TDMS Channel exists for an IIF command

I am filling in PDF files with TDMS data.  Sometimes all tests are run.  Sometimes only some tests are run. 

 

I want to fill in spots of the PDF with N/A if the tests were not run.  Is there a boolean to use to check if a specific channel exists? (Diadem 2012)

0 Kudos
Message 1 of 12
(4,634 Views)

Hello Dfjjbn,

 

The following method returns a true/false on a channel name in the first group of the data in your DataPortal:

 

 

msgBox data.Root.ActiveChannelGroup.Channels.Exists("Time")

I hope that helps,

 

     Otmar

Otmar D. Foehner
0 Kudos
Message 2 of 12
(4,624 Views)

I am trying to get a block in a table to either put test data in or put an "N/A" if the test was not run.

0 Kudos
Message 3 of 12
(4,586 Views)

The best is to use and if then statement, the folowing is the easiest way i have come accross.

 

If CNo("MyChannel") <> 0 Then

' script to insert test data 

Else

' script to insert N/A

End If

 

 

CNo("MyChannel") will return 0 if dosn't exist.

Message 4 of 12
(4,577 Views)

I don't have scripting.  I am trying to do this in the Text Entry Window.

0 Kudos
Message 5 of 12
(4,571 Views)

You can still use commands and variables in the Text Entry Window, even without scripting.  Try this:

 

@@IIf(CNo("My Channel")<>0, "Channel Exists", "Channel Does Not Exist")

 

Of course you'll want to edit the command to use the name of your channel and the appropriate string/data information for the true/false cases. 

0 Kudos
Message 6 of 12
(4,537 Views)

That is the closest I have gotten.  When the channel is there I get the second response in your case"Channel does not exist".  But when the channel does not exist I still get an error and not a "Not Tested".  I am trying to avoid that error.

 

My line is

@@IIf (CNo("Ch[5]/Current")<>0, str("Ch[5]/Current"), "Not Tested")

 

With the channel in my data, I get "Not Tested"  when the channel is missing I get a blank and an error.

 

thanks

0 Kudos
Message 7 of 12
(4,529 Views)

@@IIf (CNo("[5]/Current")<>0, str("Ch[5]/Current"), "Not Tested")

 

Got It thanks.

0 Kudos
Message 8 of 12
(4,519 Views)

I then need data from a property of the channel.  When the channel is not there I get error messages because the TRUE portion can not be evaluated.

 

Any tricks around this?

 

@@IIf (CNo("[5]/Current")<>0, str(ChnPropValGet("[5]/Current","RMS")), "Not Tested")

 

This gives an error when the channel is not there.

0 Kudos
Message 9 of 12
(4,514 Views)

Hi Dfjjbn,

 

A frustrating limitation of the IIF() function is that it always evaluates both the true and the false expressions, regardless of the boolean value of the first parameter.  This is therefore not a clean branching, which is what you need here.

 

What exactly are you trying to accomplish?  Where does that property value end up in DIAdem when it exists and the IIF() statement runs without error?

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 10 of 12
(4,343 Views)