How to find unused elements of types/structures?

Hello everyone,

Is there an easy way like with a script/tool/AS feature to find unused elements of structures and user data types in AS4/AS6?

I’d love to hear any ideas or suggestions!

Thanks in advance for your help!

1 Like

Hello Melanie,

the element of the structure may be used in a different configuration or project, which is why no tool can say for sure whether the element is unused.

MfG

Stephan

1 Like

This is likely something for an AI to either do or help you write the script, as such an algorithm (regardless of script/tool/AS feature) would need to identify every element of every datatype and then count there uses throughout the code. It would need to understand all referencing, pointers, arrays, that are using said datatype.

I’ve used Microsoft copilot to help me script things in the most basic sense of this in powershell and then execute this during build with AS pre-build/post-build scripting. (i.e. it traversed the project structure and removed .bak files created by WinMerge/VS Code/Notepad++).

If you create such a tool/script, it would be awesome for you share back with the forum.

1 Like

Hi @scme , have you found solution for your issue? can you update us and maybe close the topic?

I will post a solution here, as soon as I find time to build a script or something like that. You can close this topic for now.

1 Like

I came across this thread because I was looking for a script like this and decided to go ahead and make something. I did this with a lot of help from Copilot so if you find any issues you can blame the AI :wink:

Just extract the script and run it with Python. It will ask you for an AS project directory and warn you if the directory is invalid. Then it will:

  1. Search every .typ file in the directory to create a list of data structure members
  2. Search every .st, .c, .iom, and .vvm file to see if those members are used anywhere

You can modify the search parameters if you want to. Also, it will NOT look at anything in the Libraries folder (or any folder named Libraries). Before I added that, I got a huge list because most projects aren’t going to use every single function in the mappMotion libraries for example.

It will output the list to a text file that will be placed in the same directory as the script.

FindUnusedStructureMembers.zip (1.5 KB)

3 Likes