From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

"Run VI when opened" from lvproj doesn't work

Solved!
Go to solution

Here's the setup: I'm making a VI that duplicates a test template (vilib) and it's associated build specs within a project. My idea is to have a VI that the user (developer) opens and which presents a dialog (select template, enter name of new test, GO). Ideally this VI will simply run when opened. 

 

If I create a VI and set it's execution proerties to "Run when opened" and open it from the OS's file browser, the VI behaves as expected: it runs. If I open the VI from anywhere within a Project, it does not. Why would this be? Is there a workaround?

 

_____________
Creator of the BundleMagic plugin for LabVIEW!
0 Kudos
Message 1 of 17
(4,339 Views)

I noticed the same behavior. You can right click the VI and press Run

0 Kudos
Message 2 of 17
(4,321 Views)
There is no way to "work around" things that aren't broken. The behavior is what is intended. If it weren't, how would you ever open such a VI to edit it?

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 3 of 17
(4,305 Views)

HI Mark, thanks for the snarky reply! I'll ignore that and go on to say this is not the expected behavior according to my expectations. Your rhetorical question would apply to a VI opened from the finder: how would you edit it? You'd stop the VI from running and switch to edit mode. Did you have in mind that once a VI is running it can no longer, ever, be edited? That would be strange behavior indeed.

 

 What difference does it make if I open a VI from a project of the OS? I'm *opening* it.

_____________
Creator of the BundleMagic plugin for LabVIEW!
0 Kudos
Message 4 of 17
(4,293 Views)
No, your expectations are simply incorrect. What you see is the designed behavior.
0 Kudos
Message 5 of 17
(4,283 Views)
1. The name is "Mike". It is both my name and my userid.
2. Since when is telling the truth snarky?
2a. If you think that comment was snarky, wait till you get out of school. I'm a cupcake...
3. What you said about the finder is exactly how it used to work before there were projects. On the Mac at least.
4. What about VIs that are programmed to close themselves when they stop? You can't switch them to edit mode.
5. Why would you expect that opening a VI in a development environment start it running?

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 6 of 17
(4,272 Views)

I don't know about expectations, but I do know that I personally don't much like auto-running VIs. Rather than go that way, I would suggest you integrate the VI into the LV editor like other tools do.

 

One way to do this would be to place it in the Tools menu and you can see some details here - https://decibel.ni.com/content/docs/DOC-5957

 

Another would be to integrate it into the right click menu in the project, but for that you need to create a project provider, which is more complicated and requires some coordination with NI. There's a dedicated group for that in the communities area.


___________________
Try to take over the world!
0 Kudos
Message 7 of 17
(4,252 Views)

Thank you Gregory, this is the only answer that gets me anywhere. It still does not explain why Run when opened doesn't work from a project, but it does help to know it's possible via a workaround.

_____________
Creator of the BundleMagic plugin for LabVIEW!
0 Kudos
Message 8 of 17
(4,205 Views)

Dear Mike,

 

Telling the truth isn't snarky. What is snarky is telling people that their expectations are incorrect. Snarky is taking a high handed and arrogant approach to others. I have a PhD and 20 years experience in the work world, and I don't deal with people in my daily life who treat me with disrespect and unkindness. And you, dear cupcake, did not provide an answer to my question or an explanation of why you think my expectations are wrong. Either would be welcome. Anything else is clogging the discussion.

 

The question remains: why is opening a file from the project different than opening a file from the OS? Why would NI provide an option to "Run when opened" if this did not describe the expected behavior? What should a developer expect this option to accomplish, if not to run when opened? Under what circumstances will this option have the expected behaviour. 

 

These are all the same question, and a reiteration of the original question, which remains unanswered. I suspect that the designer of the functionality would need to tell us. I am not omniscient in that regard. But cupcakes think they are.

 

 

_____________
Creator of the BundleMagic plugin for LabVIEW!
Message 9 of 17
(4,200 Views)
Solution
Accepted by topic author littlesphaeroid

Alright lets take a deep breath... 

 

Disclaimer, the following text is my opinion based on my knowledge of LabVIEW and not the inner workings of NI, I could be wrong about why decisions were made:

 

This feature in my opinion was put in many years ago, as a cheap and dirty way to make it appear as if a VI is executable code (which is sorta can be but shouldn't be treated exclusively as).  Years ago if you had some code and you wanted a user to double click an icon and have it start running you would make an EXE.  Well that required the application builder which was extra money and it was a decent amount of steps involved.  The new users of LabVIEW complained that this was too difficult and wanted a way to just double click a file and have it run so NI added this function.  NI also tried making it easier to do by adding additional items in the Tools menu to eliminate steps.  Now if you double click a VI with nothing else open, which had this run when opened setting on, it would open and run it in LabVIEW.  Running source code as an application has several pitfalls and issues, and in other (non scripting) languages this would not be tolerated.  But it was a hacky way to make the beginners of LabVIEW happy.

 

Later on LabVIEW got projects and a easier way to make EXE (still requiring the application builder).  Now using source from a project, looked and behaved more like source from other text based languages.  In this regard opening a VI would be the equivalent of opening a text file in notepad.  And having the behavior of opening text and having it automatically start running from your source would be a bad thing.  The state of source can easily be modified which is one of the reasons binarys should be used in these situations.

 

So for the most part this feature is old and busted.  It probably shouldn't exist at all, and the fact that it does exist stems from NI bending to the will of those who might not know what was best for the language as a whole.  That feature should either be removed all together, or be updated to run when opened from a project which I hope I made clear is probably not the best solution.  A third option would be to just update the documenation stating the current behavior.

 

If you want to run a VI when opened use this feature, but open the VI not from the project.  Instead just open the VI from your file explorer, or from File >> Open in LabVIEW.  Opening it from a project is telling the IDE you are trying to edit the source, in which case it shouldn't run when opened.

 

The good news is NI has a place where you can suggest new features or improvements for LabVIEW.  If there are people who agree with your new idea they kudo it, and enough kudos causes NI to consider these features.  If this is important to you, and a suitable work around doesn't exist I'd suggest making a post there.

Message 10 of 17
(4,184 Views)