Jump to content

Removing Items with No Callers from lvproj


Recommended Posts

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.

Link to comment

Here are some options:

  1. It's possible someone already did this. I seem to have a vague recollection of this, but I'm not sure.
  2. 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.
  3. 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.

  • Like 1
Link to comment

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.

Link to comment

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.

Link to comment

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.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.