Val Brown Posted June 29, 2012 Report Share Posted June 29, 2012 I have a project file that has a rather large number of now orphaned items in it and I'm wondering if anyone can come up with a great idea for a VI to course through the project and removing those items. I really don't want to have to slog my way through doing it manually. Quote Link to comment
Yair Posted June 29, 2012 Report Share Posted June 29, 2012 Here are some options: It's possible someone already did this. I seem to have a vague recollection of this, but I'm not sure. It might be easier to just build a new project with just the VIs you want. I usually try to keep only the VIs I actually need to access in the project. You might be able to drag virtual folders from one project window to another to speed this up, although I'm not sure about this. I would expect that writing a VI like the one you want shouldn't be that hard, assuming you have a small number of main VIs which hold the others in memory. Basically, you need to open the main VI and get all its dependencies (either through the Get VI Dependencies method or by recursively using the Callees property on all the subVIs. Once you have that list, You need to iterate though all the VIs in the project and see if they're on that list. If they're not, they're either orphaned or a top level VI and you should already have a list of top level VIs (in fact, they can be part of the first list). I'm assuming there's a method you can use to remove VIs from the project at that point, but I haven't looked for it. Of course, one more thing you would want to consider at this point is deleting the VI (presumably you don't need it anymore if no one is calling it). And one more of course - you would want SCC so that you can revert if something goes wrong. 1 Quote Link to comment
asbo Posted June 29, 2012 Report Share Posted June 29, 2012 It's possible someone already did this. I seem to have a vague recollection of this, but I'm not sure. I have the same vague recollection. How may vague recollections make an actual recollection? Quote Link to comment
Darren Posted June 29, 2012 Report Share Posted June 29, 2012 You can right-click on the top-level project item and choose "Find Items with No Callers". This should generally do what you want, with a couple of caveats: 1. Your top-level application VI(s) will be listed, so ignore those. 2. Items in Dependencies will be listed. "How is something with no callers in my Dependencies list?", you may ask. Well, unfortunately, if there is a library in your Dependencies, then any VI in that library that you don't call in your code will be listed in the "Find Items with No Callers" results. I've been meaning to add an option to that dialog to ignore Dependencies for years, but I haven't gotten around to it. Quote Link to comment
Val Brown Posted June 29, 2012 Author Report Share Posted June 29, 2012 You can right-click on the top-level project item and choose "Find Items with No Callers". This should generally do what you want, with a couple of caveats: 1. Your top-level application VI(s) will be listed, so ignore those. 2. Items in Dependencies will be listed. "How is something with no callers in my Dependencies list?", you may ask. Well, unfortunately, if there is a library in your Dependencies, then any VI in that library that you don't call in your code will be listed in the "Find Items with No Callers" results. I've been meaning to add an option to that dialog to ignore Dependencies for years, but I haven't gotten around to it. Yes, I've done that but all that does is list the files but I don't believe I can remove them from that project via that window. And thanks to everyone for their suggestions so far. Quote Link to comment
ned Posted June 29, 2012 Report Share Posted June 29, 2012 If you only have one top-level VI, aren't loading VIs dynamically, and have a simple folder structure within your project (for example, virtual folders matching exactly what is on disk), it might be simplest to save the top-level VI to a new location. Choose the option to save the entire hierarchy, then recreate the project. Quote Link to comment
Phillip Brooks Posted June 29, 2012 Report Share Posted June 29, 2012 Sounds like a sourcender situation to me... Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.