LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

using a for loop for dynamic registration

I am able to register events discretely, but when I attempt to do the same thing in a for loop, my code fails to work, and I don't see the difference between my two approaches.  First, the method that works:

works.pngNow, the method that doesn't work:

 

broke.png

 

In addition to this shift register, I have also tried using tunneled output from the for loop, with both indexed, tunneled, and concatenating outputs.  When I say the 2nd approach doesn't work, what I mean is that the event structure never executes.  I made sure to go into the event editor and change the event to be the dynamic one that I'm registering...

 

Any thoughts?

0 Kudos
Message 1 of 7
(2,420 Views)

In the second method that doesn't work you are registering ONE event instead of all of them.

 

In the first example you build four arrays then register each array as an event in the same node.

 

In the second example you build four arrays the concatenate them to form one larger 1D array.  You then auto index the array so that each iteration the next item in the array replaces the last one.  The shift register makes it so that the event reference is replaced each iteration as well.  After the final iteration you pass the single event reference containing only the last control reference to the node on the event structure, thus registering only the last digital control.

 

Kelly Bersch
Certified LabVIEW Developer
Kudos are always welcome
0 Kudos
Message 2 of 7
(2,398 Views)

thank you for the clear explanation....

 

Is there a way to use a loop to register them all?  As you know, when you bring the node out of the for loop, it's an array.  I can't connect an array to the dynamic registration input of the event structure, it gives an error.

0 Kudos
Message 3 of 7
(2,392 Views)

Why do you want to use a loop when your first method works?

 

Kelly Bersch
Certified LabVIEW Developer
Kudos are always welcome
0 Kudos
Message 4 of 7
(2,384 Views)

because this is a small scale test and in the full version there may be up to 100 separate arrays of controls that I would want to register.

0 Kudos
Message 5 of 7
(2,380 Views)

In your example, each group of controls for which you want to register contains three booleans and a numeric. On the front panel, are these groups similar or identical? Can you group the three booleans and numeric into a type-defined cluster? Then you can register for events on the cluster instead of on the individual control, which may make things easier. It is also possible at that point to iterate through every control on the front panel and build an array of all the ones that match that type definition, then register for events on that array.

0 Kudos
Message 6 of 7
(2,365 Views)

Let me jump in here (now that I've seen this thread and caught up).  Bmishoe's statement about trying to register for multiple events within a loop was based on something I told him in a different thread.  how to merge event structures?.

 

I thought I had seen an example in the past where you could essentially build up on multiple registrations within a loop.  It's possible I was mistaken.  I can't seem to find a message or example that demonstrates that as I try to look for one now.

 

Is it possible that I am confusing dynamic event registration with something I might have seen for User event registration?

Maybe I saw this idea Allow the addition of new event sources to the Event Registration Refnum and that stuck in my head?

 

One thing I did find that would be useful reading is Nugget of the week: Dynamic event registration

0 Kudos
Message 7 of 7
(2,340 Views)