You could build a log table into which to add a record every time any script is run.
You would also need to modify ALL scripts to include a subscript that creates this record (passing the script name in use as a variable to the subscript to log that info).
This is a LOT of work. And, when you're done, you have to wait around for however many days, months, or years before compiling the results into a subsummary report which shows the names of every script run during that time. Then, if you've waited long enough, you might be safe in assuming that scripts not listed are not used.
I recommend using the Database Design Report (DDR) tool in FMP Advanced and identifying scripts which are not called from either other scripts nor buttons.
If you have a multi-file system, this takes some work to check through all files' reports for external script calls as well as local references in the same file.
Of course you'll need a place to store your list, assuming this is a multiuser system, it can't be a global field, so if you don't have a table for constants you'll need to create one (I generally do this with a table with only one record, and a field set to "1" in each table so I can make a constant relationship to pull data from that table)
Then simply add a few line to the scripts that are in question:
Set Field(ScriptList;ScriptList & " " & Get(ScriptName))
You should be able to just copy and paste those 3 lines into each script you need to check, give it some time and you'll know which of those scripts have been used. You might want to replace the space I put in with a carrage return to make it easier to read.
I have definitely been using the DDR but having multiples it is really difficult to jump around. Using Control + F within the browser is a great trick but is still very time consuming. Is there a way to overview all files on one page using DDR? Or will I have to click back and forth between them? Could I maybe use "Send Mail" at the end of my scripts to send myself a email using Get(scriptname)?
Thanks much. I am trying to find a way to not have a go and add to any scripts seeing that I do have multiple files and in just one of them I have over 400 scripts.
Run your DDR through BaseElements - it can tell you which scripts are unreferenced.
Neat idea! I will try that one myself when I get back to that part of our file cleanup....
You could try using BaseElements. It will tell you what scripts are connected to buttons and menus.
Thanks guys much. Works great.
1 of 1 people found this helpful
Keep in mind that the DDR and BaseElements have one shortcoming over actually tracking the use of scripts in live-time. They will tell you which scripts are no longer referenced by buttons or other scripts, but they can't tell you if still-referenced scripts are actually being called any more.
I now for a fact that our system has fully-referenced scripts which are obsolete, along with some old copies of layouts containing buttons which would still call those scripts -- if anyone ever used those buttons, but they don't. Tracking those down and clearing out the deadwood is a lot more work than just identifying structurally-orphaned items in the system.
Buy, hey... cleaning out the stuff that you can verify isn't referenced is a huge headstart on an overall cleanup plan.