LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Setting Array Index

Solved!
Go to solution

@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.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 11 of 15
(43,208 Views)

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.

0 Kudos
Message 12 of 15
(43,191 Views)

@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:

prettypwnie_1-1581015811338.png

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....

0 Kudos
Message 13 of 15
(43,183 Views)

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:

 

Spoiler

 

I do not have a valid LV license so I have to rely on memory...

 

Spoiler
Until the free for private version of LV hits the streets.

 

 

 

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 14 of 15
(43,148 Views)

This seems to work (and it lets you specify any index):

gav.png

"If you weren't supposed to push it, it wouldn't be a button."
Message 15 of 15
(43,142 Views)