02-06-2020 04:53 PM - edited 02-06-2020 04:55 PM
@PhoenixCall wrote:
Prettypwnie,
Thanks for the reply.
This is a large application that performs most functions in subVIs (already created) which use the reference and the active element to determine what data to work with. When the user clicks on an element in the data array the front panel is updated with the selected data and that data is manipulated and placed into database tables. All the other functions are already in place. If I use the index array function, I will be able to update the front panel, but all the other operations happening with the data and database are going to be using the data array active element (making wrong data in the database).
Again, I can use the index array, it would mean rewriting a lot of the code, which I was trying to avoid.
If you have any other ideas I'm open to hearing them.
Thank you for taking time to consider my issue.
I would seriously consider refactoring your code. It is a VERY good practice to separate your business logic (the code that does the real work) from the UI. As you have discovered, passing references around to your subVIs is very problematic and it complicates things. It also tightly couples your subVIs to this particular UI. Your subVIs should be expecting the actual data, not references to UI elements that have the data. That way you can be very confident you are acting on the correct data and not coming up with complex code to make sure that your subVIs are operating on the right data.
If I pass a reference to a control to a subVI, the only operations I expect those subVIs to perform are UI related functions. If I am manipulating data, writing to a DB, analyzing it I pass the data itself.
02-06-2020 09:13 PM
Prettypwnie,
Thank you for sticking with me on this. The solution was much more simple than I expected.
Everyone who mentioned refactoring, you are right, that is the best choice. I really appreciate everyone's replies. It make the community a nicer place when your question doesn't go unanswered. Big thanks again to you all.
02-07-2020 02:41 AM
@prettypwnie wrote:
Okay, I think I see what you're wanting. I don't think it's a good idea to have your program dependent on the array element focus like that, but I guess if the code's already written, maybe you don't have budget to change it.
I tried hacking around and here's something that might work for you:
Maybe defer front panel updates if it flashes (though I didn't see any when I tried it)
That only works correctly if the array index is 0. If that's not always the case, you need to read it, set it to 0, and then set it back....
02-07-2020 02:00 PM
Not sure if the following thoughts can help out but...
This Nugget about control references touched on the fact that only the element shown in the top left... can be accessed.
Now if we are just trying to figure what value changed, a value changed event will return the before and after that can be used to discover what changed.
Then another approach could use (is it a table?) where there is a method ( not a property) that will translate the mouse down coordinate to an active cell taking into consideration scroll bars etc.
Ben
Disclaimer:
I do not have a valid LV license so I have to rely on memory...
02-07-2020 02:50 PM
This seems to work (and it lets you specify any index):