DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

expected ')'

I suspect this is something simple, maybe a case of temporary blindness.

I keep getting the subject error when I try to execute the following line, despite trying multiple different configurations and various attempts to make it go away.

I've scoured google and the NI forums, and it seems this is such an elementary problem that there is no documented answer.

** I dim i, j earlier in the code

 

SG7NAME = "["&i&"]/SG7 STRAIN"

j = ChnFind("Ch("&SG7NAME&") >= 0.001")

 

I have no idea what its problem is here - I open and close my parentheses to define the Ch reference, and I open and close my parentheses for the ChnFind Function... seems pretty cut and dried. At this point, I think I don't know what question I should be asking, so I'm coming to the forum.

 

Thanks in advance for any help!

0 Kudos
Message 1 of 5
(146 Views)

Ok, update - I was playing with this phrase in the calculator, and dropping the channelgroup identifier and accompanying backslash makes the error go away. I had tried just using the backslash (like I normally do to implicitly reference the active channelgroup), but that also threw me an error. Getting rid of both worked..

 

ChnFind( "Ch(""SG7 STRAIN"") >= 0.001")

 

I guess at this point, my question is if the Ch(...) reference variable (according to the help pop-up) rejects the typical "[ChnGrp]/[Chn]" format? 

So in a script when I'm iterating through a series of channelgroups, would this Ch(..) variable automatically act on the channel of that name in the active channelgroup? Could end up being clunky in some situations, but not the end of the world as long as I'm sure of how it works. 

 

Still hoping for comment from somebody more learned than I, as the diadem help document for ChnFind() definitely shows channelgroup referencing going on - just not with the bracketed numerical reference like I'd want to use in a loop. Hoping to understand what I don't understand here..

 

Thanks again.

0 Kudos
Message 2 of 5
(133 Views)

E_Vorisek,

 

I'm a big fan of using channel object variables and resolving those variables outside of other functions, such as ChnFind() or Calculate().  Here's how I would accomplish the task you described:

Dim i, Groups, Channel, Symbols
Set Groups = Data.Root.ChannelGroups
Symbols = Array("SG7")
FOR i = 1 TO Groups.Count
  Set Channel = Groups(i).Channels("SG7 STRAIN")
  j = ChnFind("SG7 >= 0.001", 1, Symbols, Array(Channel))
  Call LogFileWrite("i = " & i & " , j = " & j)
NEXT ' i

Brad Turpin

Principal Technical Support Engineer

NI

0 Kudos
Message 3 of 5
(90 Views)

Thanks a lot Brad, worked great!

 

Totally different concept, but once I figured out what you were doing there it was very straight-forward. 

I didn't understand at first how the array() function was used in ChnFind(), so I tried storing all of my variables in the same array and referencing individual elements in ChnFind(). When that didn't pan out for me, I realized what was going on and things made more sense. 

 

In this whole process, I found the PnO() and CMax() functions, which worked well for me in another section of my code.

It seems like I could potentially have used PnO() instead of ChnFind() in my above application.. is there a situation where ChnFind is preferable or has functionality that PnO() does not?

 

Really appreciate your quick assistance.

 

Emmett

 

0 Kudos
Message 4 of 5
(65 Views)

Hi Emmett,

 

I thought about mentioning PNo() as an alternative, but I didn't want to dilute my message in that first answer.

 

PNo() always finds the closest match to the value provided in the channel provided.  PNo() will always return a valid row number, meaning there will always be a least-worse-fit row that it will return.

 

By contrast, ChnFind() will return a 0 when the condition(s) provided return no matches.  The other fundamental difference is that ChnFind() uses one or more conditions that reference one or more channels.  PNo() only ever compares to a value and only ever searches through one channel.

 

Brad Turpin

Principal Technical Support Engineer

NI

0 Kudos
Message 5 of 5
(31 Views)