LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

LabVIEW scripting - search multiple nodes, and replace by subVI

Dear LabVIEW community,

 

let me ask you about the following. 

 

I have some old project, and I'd like to clean up it a bit.

There are many repeatable pieces of code, which could be substituted by subVIs - I guess, it's classical situation.

Idea is to create subVIs, and replace that parts of code - but I'd like to automate it a bit.

It would be great, if it'll be possible to create some scripting tool, which will check subVI and its input content, and then analyze other VIs -> find same piece of code as subVI has -> replace that piece of code by subVI.

 

But,if there are many different subVIs to replace with, such task is quite tough - because you need to write algorithm for each part of code, to search exact pattern. 

 

Question is - are there some examples, of how to nicely implement search of multiple specific nodes in the VI? Is there some kind of template/example of it? Orf as each case is individual, everything should be written from the scratch?

 

Thanks a lot in advance,

 

Sincerely, kosist90.

0 Kudos
Message 1 of 4
(1,880 Views)

I've seen a lot of scripting code in my day, and I've never seen anything like what you're asking for. It seems to me that it would be faster to meet in the middle...write a VI Analyzer test that will detect the multi-node pattern you're looking for, then go in and manually drop the new code in those places that are detected.

Message 2 of 4
(1,849 Views)

Yes, it could be the way to go - but for me now question is not how to implement replacement, but how to nicely implement search of multiple nodes.
Because there are a lot of different pieces of code to search for, and to implement custom search pattern for each of them would be time consuming. So I'm just wondering, if there are some templates for it - because when I check LV examples for scripting, I don't see something like "Search multiple nodes". Maybe, "Navigating Nodes and Wires" is what I need to use, but it is also not universal...
But, I guess, this is the only way to do it?

 

Thanks a lot,

Sincerely, kosist90.

0 Kudos
Message 3 of 4
(1,839 Views)

That is funny, I'm actually working on something you describe. An advanced search and replace (UI driven, but hopefully with some even more powerful API's as a bonus) .

 

I'm at the first step (get\set properties by their name, call methods by their name), but when\if I get it working, it will be able to do what you want. It's one of the more advanced use cases, so it might be useful sooner...

 

The scripting API is capable of searching nodes. Checking if they are connected is also possible. Cumbersome, but possible.

 

Typically, you should be happy if you get 80% of the task done automatically. 100% is often out of the question and could easily multiply your development time by 20.

 

Part of the problem is that there are many (potential) ways to do it. Going from one direction to another could mean a complete rewrite. In your example, you can traverse for one node, and check all connected wires, check all the nodes connected to it, and check if they match. Another route would be to traverse for all nodes, and check if they are connected. Jet another route would be to traverse for all wires, and check their connected nodes... And it's not always plain to see if a solution is viable before it's completely done.

Message 4 of 4
(1,834 Views)