cancel
Showing results for
Did you mean:

## ChnFind- another subchannel

Hello all,

I have a channel like follow

Content     Time           Value

1               0.1            15

2               0.2            20

3               0.3            30

4               0.4            40

I used formula t1= chnfind("Ch(""I"")>20") and return me value "3" from Content area. How can I use chnfind function, or another function to return Time value ? In this example to return me "0.3"?

Thank you!

Message 1 of 4
(527 Views)

## Re: ChnFind- another subchannel

Hi Alex_SI,

ChnFind returns the row where the condition is true for the first time. This can be used to get channel content of other channels. Here is a more formalized example for this request.

``````dim oSourceChn, oSearchChn, iIndex

set oSourceChn = Data.GetChannel("[1]/Speed")
set oSearchChn = Data.GetChannel("[1]/Time")

dim sFormula, aSymbol(2), aValues(2)
sFormula = "A >= B"
aSymbol(1) = "A"
aSymbol(2) = "B"
Set aValues(1) = oSourceChn
aValues(2) = 30

iIndex = ChnFind(sFormula, 1, aSymbol, aValues)
if iIndex > 0 then
msgbox oSearchChn(iIndex)
end if``````

Greetings

Walter

Message 2 of 4
(511 Views)

## Re: ChnFind- another subchannel

Thank you, if I will formula "divede by 10" (10 is samplerate) to get Time Value it will be OK? What do you think?

Message 3 of 4
(501 Views)

## Re: ChnFind- another subchannel

I am not sure what exactly mean, but you can of course extend the formula:

``````dim sFormula, aSymbol(3), aValues(3)
sFormula = "A >= B / C"
aSymbol(1) = "A"
aSymbol(2) = "B"
aSymbol(3) = "C"
Set aValues(1) = oSourceChn
aValues(2) = 30
aValues(3) = 10``````

Greetings

Walter

Message 4 of 4
(492 Views)