LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

find and replace global variables

Hi there,

 

I've ran into a mess with my global variables. While I was trying to rename one of the globals, all instances in hundreds of subvis turned corrupt. The icon of the global variable turned black and the wires starting at the variable became broken. The amazing thing is that the black icons seem still to be linked to the correct global variable. If I leave the mouse cursor on the icon, the correct file path appears in the context help window. If I double click on the corrupt icon, the correct vi is opened. I tried "Save as" and "Rename" with various options. LabVIEW seems to browse through all affected vis but the icons remain broken. My last hope was to run the "Find and replace" tool (Ctrl + F), but it doesn't work for global variables for some unknown reason, unfortunately. Compare

 

http://forums.ni.com/ni/board/message?board.id=170&message.id=438450&query.id=2151294

 

 

Is anybody out there who has a useful hint?

 

Peter

0 Kudos
Message 1 of 9
(5,522 Views)

Hi stoeckel,

 

wow, globals in hundreds of subVIs...

 

Probably LabView only lost the connection to an item of the global VI, but not to the global VI itself. Did you rename any of the items?

 

My suggestion: Pick a recent backup and replace the broken global with it's older version.

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 9
(5,519 Views)

Hmmmm... Global variables and a mess. Gee, these two always seem to crop up together. Smiley Very Happy

 

It sounds like you were renaming a global without all of the VIs loaded into memory. The safest way to handle changes in global variables is to make sure all VIs are loaded into memory. Thus, when the global variable is renamed, all of the links are updated in-place and you can save all of the updated VIs.

0 Kudos
Message 3 of 9
(5,498 Views)

finding global variables are a pain before you have broken them. Finding a global variable sucks anyway since it ctrl-f will find all globals on the same global vi not just a single instance.  One thing you can try is to go to the brojen global and see the lable text associated with it, then do a find on text instaed of a find on the global.

 

Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
0 Kudos
Message 4 of 9
(5,495 Views)
Also find text will find the text inside the name of the broken global (the lable will most likely be the name of the global vi it comes from and the case text is probably the old name which was not updated).
Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
0 Kudos
Message 5 of 9
(5,485 Views)

Hi there,

 

thank you all for your contributions. We were able to solve the problem in the meanwhile. Why did nobody point us to the fact that the icons of global variables turn black if the name of the control on the panel of the variable does not match the selected name inside the icon?

 

If somebody just quietly mentions the existence of "global variables" he or she will usually be soused with flout and bashed by the proven active veterans. But why's that? Global variables can provide an easy way to communicate a "stop" information throughout all running vis. As long as there is just one writer and many readers, there is no danger that it comes to "race conditions".

 

If global variables are really so nasty as is often said, why does National Instruments still provide them within LabVIEW??

 

Peter

0 Kudos
Message 6 of 9
(5,432 Views)

stoeckel wrote:

Hi there,

 

thank you all for your contributions. We were able to solve the problem in the meanwhile. Why did nobody point us to the fact that the icons of global variables turn black if the name of the control on the panel of the variable does not match the selected name inside the icon?

 

If somebody just quietly mentions the existence of "global variables" he or she will usually be soused with flout and bashed by the proven active veterans. But why's that? Global variables can provide an easy way to communicate a "stop" information throughout all running vis. As long as there is just one writer and many readers, there is no danger that it comes to "race conditions".

 

If global variables are really so nasty as is often said, why does National Instruments still provide them within LabVIEW??

 

Peter


I'll venture a guess!

 

I did not know that fact since I avoid globals and have very little experience with them aside from them causing race conditions in the first VI I tried to use them in and a never explained delay when trying to read from them inside a Timed loop.

 

Re Why does N....

 

Good question! it has been asked by many people over the years.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 7 of 9
(5,428 Views)

stoeckel wrote:

Hi there,

 

thank you all for your contributions. We were able to solve the problem in the meanwhile. Why did nobody point us to the fact that the icons of global variables turn black if the name of the control on the panel of the variable does not match the selected name inside the icon?


The LabVIEW compiler would have told you that right away. If you click the broken run arrow on the situation you will get the message:

An item with the specified name could not be found. Select a different item from the list.

Seems pretty straightforward to me. But then, perhaps it's because I've been using LabVIEW for some time.

 


If somebody just quietly mentions the existence of "global variables" he or she will usually be soused with flout and bashed by the proven active veterans. But why's that? Global variables can provide an easy way to communicate a "stop" information throughout all running vis. As long as there is just one writer and many readers, there is no danger that it comes to "race conditions".

 

If global variables are really so nasty as is often said, why does National Instruments still provide them within LabVIEW??


I don't want to get into yet another global variable debate here. The only comment regarding global variables made in this thread was a tongue-in-cheek comment I made. I was not dissing global variable. In fact, I use them quite often. Global variables, like every other programming construct ever invented have their use. The main reason you will see the so called "proven active veterans" go crazy over global variables is that they constantly see them being abused, causing race conditions, and then have to listen to newbies complain that their program doesn't work and LabVIEW sucks, when it's really their programming skills that's the real problem. But that's just my opinion.

0 Kudos
Message 8 of 9
(5,423 Views)

Dear all,

 

let there be global variables also in future! They work and serve a useful purpose if they are applied in the right way.

 

Thank you once again for your contributions. LabVIEW is a great programming language supported by a great community.

 

Peter

0 Kudos
Message 9 of 9
(5,415 Views)