Showing results for 
Search instead for 
Did you mean: 

How to find, if channel exists or not?

I am beginner in DIADEM, Apologies in advance if the question does not make sense.

If EmissionsStream1Location = "Engine Out" Then
' do this calculation

 ' ElseIf(CNo( "iD_EmissionsStream2Definition_")>0)AND( EmissionsStream2Location = "EO" and (Data.GetChannel("iD_EmissionsStream2Definition_").Properties("Equation").Value ="Ad_Emissions2RawDefinition_") ) Then
' do this calculation

  'ElseIf (CNo( "iD_EmissionsStream2Definition_")>0)AND(EmissionsStream2Location = "EO" and (Data.GetChannel("iD_EmissionsStream2Definition_").Properties("Equation").Value ="Ad_Emissions3RawDefinition_")) Then
' do this calculation

 ' ElseIf (CNo( "iD_EmissionsStream2Definition_")>0)AND(EmissionsStream2Location = "EO" and (Data.GetChannel("iD_EmissionsStream2Definition_").Properties("Equation").Value ="Ad_EmissionsDiluteDefinition_"))Then
' do this calculation

 'ElseIf (CNo( "iD_FTIRStream1Definition_")>0)AND(FTIRStream1Location = "EO" and (Data.GetChannel("iD_FTIRStream1Definition_").Properties("Equation").Value ="Ad_FTIRStream1Definition_"))Then
' do this calculation

  ElseIf (CNo( "iD_FTIRStream2Definition_")>0)AND(FTIRStream2Location = "EO" and (Data.GetChannel("iD_FTIRStream2Definition_").Properties("Equation").Value ="Ad_FTIRStream2Definition_" or "Ad_FTIRDefinition_")) Then
' do this calculation  

  else 'Just assume Bench 1 channels are Engine Out
' do this calculation

end if

In the above code, i intend to check if the channel exists at first place, if so check other 2 conditions which are lets say EmissionsStream2Location = "EO" AND go that channel and the check the Equation property, weather if its the same i need, which i specified in above code.
But upon running it, its throwing error if the channel does not exist,i believe its failing at

(CNo( "Channel_name")>0)

 i have tried other option as well like:

( "Channel_name")<>""

Any help is highly Appreciated, Thanks in Advance!

0 Kudos
Message 1 of 2

To answer "How to check if a channel exists or not":

Call LogfileWrite(Data.Root.ChannelGroups.Exists("Channel Name"))
Message 2 of 2