DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Trouble with ChnFind

Solved!
Go to solution

I have used this function successfully elsewhere in my scripts, but for some reason I am having an issue here.

Please take a look and tell me if you see the issue....

 

  

'Determining which signals from HCM1 changed over the course of the trigger event and delay
Dim k, m, z, One, ResultsGroup, ChangeTrue, ChangeFalse, Group, Result, Zero
Set ResultsGroup = Data.Root.ChannelGroups.Add("Results_Trig") 
Set ChangeTrue = ResultsGroup.Channels.Add("HCM1_ChangeTrue_Trig", DataTypeString) 
Set ChangeFalse = ResultsGroup.Channels.Add("HCM1_ChangeFalse_Trig", DataTypeString) 

result = TrigEvent - 5 'TrigEvent in this case was 112, result = 107
msgboxdisp(result) 'Result=107 confirmed with this

For k = 6 to 6 'was 2 to 15 reduced to just group 6 for troubleshooting
Set Group = Data.Root.ChannelGroups(k) 
  For m = 1 to Group.Channels.Count 
  One = ChnFind("Ch(Data.Root.ChannelGroups(k).Channels(m).Name) > 0", result) 
  Zero = ChnFind("Ch(Data.Root.ChannelGroups(k).Channels(m).Name) = 0", result)
  msgboxdisp(Data.Root.ChannelGroups(k).Channels(m).Name)
  msgboxdisp(One) 'all channels return 0.  Several should return 112 instead. (channel length is 1997)
  msgboxdisp(Zero) 'all channels return 0.
  If One>=TrigEvent and One <= EndDataRow then
    z = ChangeTrue.Size + 1 
    ChangeTrue(z) = Channel.Name 
  ElseIf zero >= TrigEvent and zero <= EndDataRow Then 
    z = ChangeFalse.Size + 1 
    ChangeFalse(z) = Channel.Name 
  Else
  End If 
  Next ' m 
Next ' k

 

 

Download All
0 Kudos
Message 1 of 3
(5,071 Views)
Solution
Accepted by topic author 2Pale4TX

Hi 2Pale4TX,

 

I don't understand why your ChnFind commands run at all.  You declare "k" and "m" with "Dim" as local variables, then you reference them in the ChnFind() expression where only global variables should be accepted.  Try this instead and see what happens:

 

  T1 = Data.Root.ChannelGroups(k).Channels(m).GetReference(eRefTypeNameName)
  One = ChnFind("Ch(T1) > 0", result) 
  Zero = ChnFind("Ch(T1) = 0", result)

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 2 of 3
(5,043 Views)

Thanks Brad,

Works perfectly now.  I didn't realize it had to be a Global variable.  That would explain why nothing else I tried worked.

 

Usually I enter in the actual channel like so,

One = ChnFind("Ch(""[1]/HCM1 SSM Label 114"")<3", result)

 

0 Kudos
Message 3 of 3
(5,041 Views)