cancel
Showing results for
Did you mean:

Highlighted

## How to find, if channel exists or not?

Hi,
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

' 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!

Message 1 of 2
(47 Views)

## Re: How to find, if channel exists or not?

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

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