cancel
Showing results for
Did you mean:

Solved!
Go to solution

## Get value of a Channel by row number

Hello,

I have recorded a script that calculates the N peak values of a channel and saves them into a new channel. Each channel contains the X value and the Y values of the selected peaks (PeakX and PeakY)

Now, I want to get the value of a channel on the PeakX values that I have saved from the Peaks calculation.

```Groups = Data.Root.ChannelGroups.Count

Set oMyChannel = Data.Root.ChannelGroups(Groups).Channels("PeakX")

for i = 1 to Data.Root.ChannelGroups(Groups).Channels("PeakX").Properties("length").Value
' Find the row where the "/Time" matches with PeakX calculated values
rowToFind= pno("/",oMyChannel.Values(i))'How to get the value of a 3rd channel on the rowToFind row

next```

How can I get the values of a 3rd Channel on the rowToFind row?

Martin

Message 1 of 4
(1,750 Views)

## Re: Get value of a Channel by row number

There is a function in DIAdem - "ChnFind()".  Very handy.  Example:

```Dim intMyResult
intMyResult = ChnFind("Ch(""Group1/Channel"")>10",250)```

intMyResult will contain the first row above 10 and it will start searching from the 250th row in "Group1/Channel" (speeds up search in many cases). So in your case,

`rowToFind = ChnFind("Ch(""/"")=" &oMyChannel.Values(i),1)Dim ThirdChannelValue: ThirdChannelValue = oMyThirdChannel.Values(rowToFind)`

Hope I understood you question.

P.S. there is a ChnFindReverse() function as well (starts the search from the end of the channel) Message 2 of 4
(1,740 Views)
Solution
Accepted by topic author iparra

## Re: Get value of a Channel by row number

Hi iparra,

here is my interpretation of your request:

```dim i, iRowToFind, iNewChnIndex, iLastGroupNo, oChnTime, oChnSource, oChnPeakX, oChnNew

iLastGroupNo = Data.Root.ChannelGroups.Count

set oChnTime   = Data.Root.ChannelGroups(1).Channels("Time")
set oChnSource = Data.Root.ChannelGroups(1).Channels("MySourceChn")
Set oChnPeakX  = Data.Root.ChannelGroups(iLastGroupNo).Channels("PeakX")

iNewChnIndex = 0
for i = 1 to oChnPeakX.Size
' Find the row where the "/Time" matches with PeakX calculated values
iRowToFind = pno(oChnTime, oChnPeakX(i))
'How to get the value of a 3rd channel on the rowToFind row
if iRowToFind > 0 then
iNewChnIndex = iNewChnIndex + 1
oChnNew(iNewChnIndex) = oChnSource(iRowToFind)
else
exit for
end if
next
```

Greetings

Walter

Message 3 of 4
(1,711 Views)

## Re: Get value of a Channel by row number

The link below shows how to use several DIAdem functions to get the row corresponding to a channel value.  PNo() is the easiest and fastest.