DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Find Function channel reference

Hi,

 

I'm using the find function in script to find when a certain threshold is breached in a data channel. The below script works fine but I'd like this to loop through several channel groups. I am familiar with looping but to do that I need it to accept a variable or index value as the channel and group references. Currently I can only get the script to work using string values for the channel and group name. What is the syntax for using index references? I thought it was something like [1]/[1] etc but that doesn't seem to work.

 

Thanks

 

Dim intMyResult
intMyResult = Find("Ch(""C115_800rpm_40deg_21033000912/P6 FWD Pressure [bar]"")>1",1)
Call MsgBox(intMyResult)

0 Kudos
Message 1 of 4
(2,061 Views)

Solved, not sure what I was doing wrong but the below is working now. 

 

Dim intMyResult
intMyResult = Find("Ch(""[1]/[9]"")>1",1)
Call MsgBox(intMyResult)

0 Kudos
Message 2 of 4
(2,050 Views)

Seems I spoke to soon. If I replace this group reference with a variable name it now doesn't like this.

Do I need to convert from a string to an integer value?

 

Dim i,j, iloop

For iloop = 1 To 4
   i = Find("Ch(""[iloop]/[7]"")>1",1)
   j= i-30
  Call MsgBox(j)
Next

 

This gives the error that "An invalid text operand is used within the index operation of the formula"

0 Kudos
Message 3 of 4
(2,026 Views)

Hi,

 

Please have a look at this example:

 

dim oChn, oGroupChns, oGroups, iLoop
dim sFormula, aSymbol(1), aValues(2)

set oGroups = Data.Root.ChannelGroups

for iLoop = 1 to oGroups.Count
  set oChn = oGroups(iLoop).Channels("MyChnName")
  sFormula = "A > 1"
  aSymbol(1) = "A"
  Set aValues(1) = oChn
  aValues(2) = 1
  Call MsgBox(ChnFind(sFormula,,aSymbol, aValues))
next

 

Greetings

Walter

0 Kudos
Message 4 of 4
(1,964 Views)