LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how do you pass vi references from one event to another

I have a vi which gets vi references (thereby loading the vi's into memory) for all the vi's in a given directory when a user clicks a button on the front panel. To do this I use an event structure. My question is whether it is possible to have another event (user button on the front panel) which unloads the vi's from memory. I have tried passing the vi references that are initially generated to the close reference function but whenever I do I get a 'vi reference invalid' error. Does this have to do with trying to pass the vi references between one event and another? If I use a local variable simply pass a reference to another indicator and then probe it, the originally-generated refnum and the local vari
able refnum match up. However once I try to wire that same indicator to the close reference function I get the 'vi reference invalid' error. Is there a different/better way to unload the vi's from memory based on a user button click? Any suggestions would be welcome.

Jason
0 Kudos
Message 1 of 6
(2,750 Views)
Several problems with your code:

1... Bad idea to use lights as buttons. Yes it can be done, but it's not "natural".
2... If you've gotta do that, set their mechanical action to "LATCH WHEN RELEASED"
3... Because of #2, you are getting TWO copies of every array when you click the LOAD VIs light (er... button).
4... No need for the conversion from path to string and back - use BUILD PATH to append each file name to he folder path.
5... Set the BROWSE OPTIONS on your PATH control to EXISTING DIRECTORY to allow browsing of directories, not files.
6... Your code doesn't care whether the file is a .VI file, or a .ZIP file, or a .TXT file, or what. Use the PATTERN input on the LIST function to discriminate.
7... Your code is only storing the latest refer
ence, not the array of references.
8... An ERROR DIALOG on the OPEN REFERENCE function will tell you that you're getting an error. Why? You are asking to prepare a non-reentrant VI for reentrant execution (why use options = 8?)
9... Because of #8, the latest VI reference is invalid.
Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


LinkedIn

Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 2 of 6
(2,750 Views)
Thank you very much for all the pointers. A couple of them I knew and out of laziness hadn't implemented. Everything is working now, I appreciate your time.

J
0 Kudos
Message 3 of 6
(2,750 Views)
You should also place the "build array" inside a case structure wired to the error-out of the "open vi reference" and only add a reference if the open succeeds without error. In the error case, simply wire the array across.
0 Kudos
Message 4 of 6
(2,750 Views)
Agreed. Even if all my listed points are satisfied, there could be other errors (e.g., VI is broken). Error checking is your friend.
Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


LinkedIn

Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 5 of 6
(2,750 Views)
for all the vi's in a given directory

I'm not sure what you're doing, but please be aware that your code will not find VIs that are in libraries (.LLB) or subdirectories.

If that's important, you have to find LLB files separately, and look in them, and folders separately and look in them.
Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


LinkedIn

Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 6 of 6
(2,750 Views)