10 Replies Latest reply on May 7, 2012 9:20 AM by Stephen Huston

    Finding used scripts


      I need a way to log or list all the scripts that are currently in use. Maybe as it triggers it could add the name of the script to a list. I have a lot of duplicates and unused scripts sitting around and need to get rid of them. Is there a way to do this without duplicating the names so i can have a clean list of all scripts used within? thanks.



      Allied Defense Industries

        • 1. Re: Finding used scripts
          Stephen Huston

          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.

          • 2. Re: Finding used scripts

            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:


            IF(Patterncount(Get(ScriptName; ScriptList)>0)

                 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.

            • 3. Re: Finding used scripts

              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)?

              • 4. Re: Finding used scripts

                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. 

                • 5. Re: Finding used scripts

                  Run your DDR through BaseElements - it can tell you which scripts are unreferenced.

                  • 6. Re: Finding used scripts
                    Stephen Huston

                    Neat idea! I will try that one myself when I get back to that part of our file cleanup....

                    • 7. Re: Finding used scripts

                      You could try using BaseElements.  It will tell you what scripts are connected to buttons and menus.




                      • 8. Re: Finding used scripts

                        I second [or third or fourth] BaseElements. Excellent tool for just this type of situation.



                        • 9. Re: Finding used scripts

                          Thanks guys much. Works great.

                          • 10. Re: Finding used scripts
                            Stephen Huston

                            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.

                            1 of 1 people found this helpful