Recent Posts

Pages: [1] 2 3 ... 10
1
The Select-Case works just as well.
2
ok, That makes sense.

My other question on this, is there a reason you wouldn't use a Select Case statement?
Something like this:
Code: [Select]

     Select Case e.PlcAddress
            Case "N20:33"
                value1 = e.Values(0)
            Case "N20:34"
                value2 = e.Values(0)
            Case "N20:35"
                value3 = e > Values(0)
            Case Else
                MsgBox " No handler for " & e.plcaddress
     End Select
3
Is either way, subscribing individually, or using NumberOfElements, better than the other?
ie, is there a performance hit one way vs the other?

And what would the difference in the datachanged event code look like if you use NumberOfElements?
The driver automatically optimizes the communication, so there will be little to no performance difference.

This is how it would look like if done the other way:

If e.PLCAddress = "N20:33" then
  value1=e.values(0)
  if e.Values.Count>1 then value2=e.Values(1)
  if e.Values.Count>2 then value2=e.Values(2)
End if
4
Archie,

Is either way, subscribing individually, or using NumberOfElements, better than the other?
ie, is there a performance hit one way vs the other?

And what would the difference in the datachanged event code look like if you use NumberOfElements?

Rich
5
If you are subscribing individually, then they will be returned one at a time:

If e.PlcAddress = "N20:33"  then
   value1=e.Values(0)
ElseIf e.PlcAddress = "N20:34" then
   value2=e.Values(0)
ElseIf e.PlcAddress = "N20:35" then
   value3=e>Values(0)
End if
6
I believe I'm subscribing to each element individually.  I just noticed the "NumberOfElements" option.
7
Are you subscribing to each element individually or subscribing to the first element and specifying the number of elements?
8
Thanks Archie, that worked.  Now, how would I pull each value from the DataSubscriber?

Basically, the code should work like this:

ElseIf e.PlcAddress = "N20:33" Or e.PlcAddress = "N20:34" Or e.PlcAddress = "N20:35" Or e.PlcAddress = "N20:36" Then

Value1 = 'whatever is in N20:33
Value2 = 'whatever is in N20:34
Value3 = 'whatever is in N20:35
Value4 = 'whatever is in N20:36

I tried using Value1 = e.Values(0), Value2=e.values(1)... but got an error saying the index is out of range, so I don't think that is the correct way to do it.
9
Support Questions / Re: Emailer threading
« Last post by Archie on June 20, 2017, 04:50:30 PM »
I finally got to the bottom of this problem. It will be fixed in the next version.
10
Try it like this:

e.PlcAddress = "N20:33" Or e.PlcAddress = "N20:34" Or e.PlcAddress = "N20:35" Or e.PlcAddress = "N20:36" Then
Pages: [1] 2 3 ... 10