Help me find old code

Hello,

many years ago I used code which helped clean up unused crud functions in my code - I suspect I got it from one of Igor sources (ftp at that time likely). It was function which created list of functions/macros in package which were not called. I am unable to find it now anywhere on my computer and would love to use it. After commenting out few thousand lines of obsolete code I assume there are quite a few functions which are not called and just slow down compile time. Anyone remebers how this package was called and if it still is available somewhere? 

Or anyone else knows how to reasonably easy create list of unused functions in set of ipf files, please?  

That is cool project. Thank you very much. Close to what I need. 

I found slightly different code than what I was looking for from 2003 called Code_map_205.ipf by D. Hamara which I tweaked in 2004 for my needs a bit. It is running under rtGLobals=1 and based on age, this may be Igor 4? I have been looking through this and it can do most of what I need, just needs different scripting. It can be persuaded to produce list of functions which are not called the "normal" way. All one needs to do is check the resulting list to verify these are not Fit functions, hook functions and other "exotic" types of calls. Considering the amount of code I want to prune, this could be life saver for me. 

I guess this is question to Wavemetrics - Igor editor/debugger clearly knows a lot about user functions already, is there information - and how easily available - about who is using each function? All I really want at this moment is to create list of all user functions in set of specific procedure files and check, that each is being called or else used. That will give me removal candidates which I can deal with. 

Call it New Year Cleanup ;-)

Oh and 2021 wish??? - right click option on user function, which will create a notebook with list all locations that function is used. Ideally such that I can right click on it and be taken there... So if I make change, I can easily fix all locations. 

In reply to by ilavsky

ilavsky wrote:

I guess this is question to Wavemetrics - Igor editor/debugger clearly knows a lot about user functions already, is there information - and how easily available - about who is using each function? All I really want at this moment is to create list of all user functions in set of specific procedure files and check, that each is being called or else used. That will give me removal candidates which I can deal with. 

To my knowledge Igor's compiler does not keep track of from where or how many times a function is called. Even if it did, such a feature would not keep track of interpreted code, such as calls to a function from Execute, from a macro, or from dynamically evaluated text in an annotation or other styled text.

It is pretty easy to test whether a function is called in compiled code by disabling it by enclosing it in an #if 0/#endif block. Even easier, you can just comment out the first line of the function, or even add a character to the very beginning (eg. "function" becomes "xfunction") and Igor's compiler will skip the function. If your code still compiles, then that function is not being called from other compiled code. You can then use Edit->Find in Multiple Windows to search for all instances of, for example, the function name. Some of the hits might not actually be calls to the function of course. But if there are no hits, then your code does not call that function.

As far as compile times goes, Igor's compiler is quite fast and you are unlikely to gain much performance by removing a dead function here and there.

Typically the slowest part of Igor's "compile" process is opening additional procedure windows that are #included. This only needs to be done the first time the code in an experiment is compiled, but it can be the primary cause of slowly opening experiments that do not contain large amounts of data. So if you can possibly remove a #include from a file, you might get faster compiles versus removing a small amount of dead code.

My approach to finding dead function code is a hack like

grep "^[ \t]*Function" *.ipf | grep -oP "[ \t]+[A-Za-z_0-9]+\(" | tr -d " " | tr -d "(" > ausg
for i in `cat ausg`; do grep -ie "$i" *.ipf | grep -q -v -w "Function" || ( echo "\"$i\" could not be found"; break )  ; done

I would save/commit current state first before removing. This also fails for functions called only via build up funcref strings.

This looks really interesting. If anyone wants to try - on Catalina this fails. macOS grep command issue - the default mac grep does not have -P (perl expression) for grep command. Apparently we need to install homebrew or Macports version of grep...   

after that it seems to be actually cool... I got list of functions to verify within few seconds. Thanks!