Home AMX User Forum NetLinx Studio

DEV Array of Multiple Ports of Same Device??

Greetings,

I am having trouble with a button event from a DEV array containing devices of the same number with different ports.
dvDevice1=[33001:1:0]
dvDevice2=[33001:2:0]
dvDevice3=[33001:3:0]

DEV dDevices[]={dvDevice1,dvDevice2,dvDevice3}

BUTTON_EVENT [dDevices,0]
{
PUSH:
  nDevice=BUTTON.INPUT.DEVICE.PORT
}

In the above example, a button event on occurs on the first device of the array, making nDevice=1. Am I doing something wrong in trying to return a value based on device port numbers?

Thanks!

Comments

  • mpullinmpullin Posts: 949
    You probably want BUTTON.INPUT.DEVICE.PORT
  • TurnipTruckTurnipTruck Posts: 1,485
    mpullin wrote: »
    You probably want BUTTON.INPUT.DEVICE.PORT

    That is what is in my code. I wrote it wrong in the forum post. Thus I corrected the original forum post.

    It still doesn't work though. I only get a button event from the first device of the array.
  • DHawthorneDHawthorne Posts: 4,584
    When something like this produces altogether unexpected results, I find if often helps to rethink the way I am doing it altogether.

    How about this on your PUSH:

    nDevice = dDevices[GET_LAST(dDevices)].PORT
  • TurnipTruckTurnipTruck Posts: 1,485
    Thanks for the suggestion. However, my problem is that the button event is only triggering on the first device of the array.

    I failed to mention that the devices and array of devices are defined in a main program. The events are in a module that has the device array passed in.
  • HedbergHedberg Posts: 671
    I just tried this and it seems to work fine. Have you "set_virtual_port_count"?

    Well, I did it in a simple Netlinx program -- not in a module. Do you need "set_virtual_port_count" in both the module and in the main program? I'm guessing just the module.
  • TurnipTruckTurnipTruck Posts: 1,485
    Hedberg wrote: »
    Do you need "set_virtual_port_count" in both the module and in the main program? I'm guessing just the module.

    I did only in the module. I've since scrapped the idea of what I was doing and went to SEND_COMMANDS.

    Thanks for your suggestion! It may just have worked.
Sign In or Register to comment.