07-01-2016 12:32 PM - edited 07-01-2016 12:34 PM
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)
07-01-2016 04:57 PM
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
07-05-2016 07:32 AM
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.
07-05-2016 08:57 AM
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.
07-05-2016 11:01 AM
I don't have scripting. I am trying to do this in the Text Entry Window.
07-06-2016 07:39 AM - edited 07-06-2016 07:39 AM
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.
07-06-2016 08:18 AM
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
07-06-2016 09:47 AM
@@IIf (CNo("[5]/Current")<>0, str("Ch[5]/Current"), "Not Tested")
Got It thanks.
07-06-2016 01:01 PM
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.
07-27-2016 04:01 PM
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