#pragma rtGlobals=1 // Use modern global access method. //#pragma IndependentModule=DependencyAnalyzer Menu "Analysis" "Analyze Procedure Dependencies",/Q,InitDependencyAnalyzer() End Function ComputeDependencies([dependsOn,dependedOn,sort_results]) String dependsOn,dependedOn Variable sort_results NewDataFolder /O root:Packages NewDataFolder /O/S root:Packages:DependencyAnalyzer String procedures=WinList("*",";","WIN:128") if(ParamIsDefault(dependsOn)) dependsOn=procedures endif if(ParamIsDefault(dependedOn)) dependedOn=procedures endif Variable i,j Make /o/T/n=0 AllFunctions="" Variable num_proc_files=ItemsInList(procedures) // Get a list of functions defined in each procedure file. for(i=0;i0 dependency_count+=called if(called) dependency_list+=defined_function1+" calls "+defined_function2+";" endif endfor endfor KillWaves /Z FunctionText,MatchingLines return 1 End Function SortDependencies(depends_On,depended_On,do_sort) String depends_On,depended_On Variable do_sort Wave DependencyCounts Wave /T DependencyDetails Variable i,num_depends=ItemsInList(depends_On),num_depended=ItemsInList(depended_On) // Depended on. Make /o/n=(num_depended) NumDependencies=NaN,DependencyIndex=p WaveStats /Q/M=1 DependencyCounts Variable total_depend=V_avg*V_npnts for(i=0;i0 NumDependencies[i]=sum(DependedOn)+tiebreak endfor if(do_sort) Sort /R NumDependencies,DependencyIndex endif String sorted_procedures="" for(i=0;i0 NumDependencies[i]=sum(DependOn)+tiebreak endfor if(do_sort) Sort /R NumDependencies,DependencyIndex endif sorted_procedures="" for(i=0;i "+GetDimLabel(DependencyCounts,1,j) details+=";"+DependencyDetails[i][j] return details End Function InitDependencyAnalyzer() DoWindow /K DependencyAnalyzerPanel NewDataFolder /O root:Packages NewDataFolder /O/S root:Packages:DependencyAnalyzer String /G all_procedures=WinList("*",";","WIN:128") NewPanel /K=1/N=DependencyAnalyzerPanel/W=(100,100,550,505) as "Dependency Analyzer" SelectProcFiles() End Function SelectProcFiles() SetDataFolder root:Packages:DependencyAnalyzer SVar all_procedures Make /o/T/n=(ItemsInList(all_procedures)) AllProcs=StringFromList(p,all_procedures) Make /o/n=(numpnts(AllProcs)) ProcSelections1,ProcSelections2 SetDrawEnv textxjust=1,save DrawText 225,20,"Check to see if functions from..." SetDrawEnv fstyle=4 DrawText 100,50,"These procedure files" DrawText 225,50,"call functions from" SetDrawEnv fstyle=4 DrawText 350,50,"These procedure files" ListBox Callers pos={25,55},size={150,320},listWave=AllProcs,selWave=ProcSelections1,mode=4 ListBox Callees pos={275,55},size={150,320},listWave=AllProcs,selWave=ProcSelections2,mode=4 ProcSelections1=1 // Select All ProcSelections2=1 Button SelectAll1 pos={55,380},size={80,20},title="Select All",proc=SelectProcFilesButtons Button SelectAll2 pos={305,380},size={80,20},title="Select All",proc=SelectProcFilesButtons Button Compute pos={200,200},size={50,20},title="Compute",proc=SelectProcFilesButtons Checkbox SortCounts pos={188,225}, value=1, title="Sort Results" End Function SelectProcFilesButtons(ctrlName) : ButtonControl String ctrlName Wave ProcSelections1=root:Packages:DependencyAnalyzer:ProcSelections1 Wave ProcSelections2=root:Packages:DependencyAnalyzer:ProcSelections2 strswitch(ctrlName) case "Compute": Variable i String callers="",callees="" Wave /T AllProcs=root:Packages:DependencyAnalyzer:AllProcs for(i=0;i