LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Is there a way to see if a subvi has something connected to a terminal?

Solved!
Go to solution
These properties are exposed through the script API a relativly new and really cool technology, essentially allows us to do things we alwars dreamed of (at least the power users) and yes this time it is open to the community.  Go to the Labview API page and download the API then activate it with the provided liscence code.  Have fun.
Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
Message 11 of 15
(744 Views)
Thanks that is really cool. I will try it.
Tim
GHSP
0 Kudos
Message 12 of 15
(727 Views)
As a side point, the scripting API is not new (it's been around for at least 7 or 8 years), but official public access to it has only been granted recently. It should be noted that scripting can be dangerous, blah blah blah, so be careful.

___________________
Try to take over the world!
0 Kudos
Message 13 of 15
(710 Views)

Darin.K wrote:

This is very quick and very dirty, but just to give you an idea.


This does not really work, e.g. if there are several instances of the subVI, and some are wired and some are not.

 

For example in the following code (slightly modified by adding an output), you can get both lit or not depending on which instance of the subVI is wired. 😞

 

Message Edited by altenbach on 12-12-2009 11:15 AM
0 Kudos
Message 14 of 15
(700 Views)

That actually just scratches the surface of issues, but that is why I couched my example in so many adjectives.  Even though it only took a minute or two to write that code, I had hoped it would serve as a bit of a cautionary tale about the effort involved.  For example, if you use a for loop, that is a separate diagram and the simple search won't find it, so now you are traversing.  Easy to lose sight of the original task.

 

But this is a great excuse to share a few observations about scripting in general.

If you don't know what Occam's Razor (entia non sunt multiplicanda praeter necessitatem) it is a good time to learn.  Do not make things any more complicated than necessary, and by necessary I usually mean absolutely necessary.  In scripting terms this means you should be solving a very specific problem.  In this case, look how complex the simplest case is, any added complications will likely double or triple the code.

 

I am almost out of letters for quickdrop shortcuts, and I have other tools as well.  Yet I only have shared a select few.  It is not (only) because I am selfish, but because to keep things managable I make certain promises to myself.  I will only call such-and-such when these items are selected, I won't do this, or that.  This works for the author of the tool, you know the trade-offs, other users just complain, it crashed when I did this and end up with a bad experience.  The difference between functioning code and robust code is quite large with scripting.

 

Finally, for now, if you find yourself using scripting functionality in an application, I would think twice.  On occasion, it provides a necessary work-around for a bug or undesirable implementation, but other than that I would tend to discourage it.  What it is intended for, and does a beautiful job of is allowing you to write tools to make writing that application easier.   Despite all of these things, scripting is probably one of my absolute favorite features of LV.  Fun, power, and an awful lot of no-mans-land, since I probably failed to mention the derth of documentation.  If I were the nugget-authoring-type, I'd do one on scripting.

 

In regards to this application, I would also like to mention that I dislike using the wired/unwired status as a switch.  The file I/O functions do this and it bugs me to no end.  I would often like to trigger a dialog by sending in an empty path or not-a-path, but I usually have to resort to a case statement, or much worse, the Express File Dialog.  If it should be wired, make it required, if it really is optional, then there should be a good default.

 

The moral of this story, Scripting Rocks!  You can do a lot, just not everything (yet).  If more of us start to use it, and push for more properties and methods, it can only get better.

Message 15 of 15
(686 Views)