{SCRIPT: COUNTING CODES} {COPYRIGHT (C) 2008, IDEA WORKS, INC.} {FUNCTION: COUNTS NUMBER OF SEGMENTS CONTAINING EACH CODE FOR PROJECT DISPLAYS WITH MOST FREQUENT FIRST} writeln(""+project.name+""). writeln("Code Frequencies"). writeln("-----------------------"). list(segcodes). list(counts). list(allcodes). list(sortedcodes). list(numcodes). list(projcodes). maxcount=0. projcodes.copyfrom(project.codes). i=1. while i<=projcodes.count do projcodes.getstring(i,code) count=0 foreach source in project.sources foreach segment in source.segments segcodes.clear segcodes.copyfrom(segment.codes) if segcodes.member(code) then count=count+1 endif endfor endfor counts.addstring(count) allcodes.addstring(code) numcodes.addstring(count+","+code) if count>maxcount then maxcount=count endif i=i+1 endwhile. {sort numerically} i=maxcount. while i>=0 do j=1 while j<=counts.count do counts.getstring(j,num) allcodes.getstring(j,name) if i=num then sortedcodes.addstring(num+" "+name) endif j=j+1 endwhile i=i-1 endwhile. display(sortedcodes).