03-16-2021 11:21 AM
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)
03-16-2021 11:25 AM
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)
03-16-2021 12:01 PM
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"
03-18-2021 02:00 AM
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