/3.0 (Extension.1 Name: "Correlation Coefficient Tool" Dependencies: "$AVBIN/avdlog.dll\n" FirstRootClassName: "Butn" Roots: 2 Roots: 4 Roots: 5 Roots: 22 Roots: 23 Roots: 24 Roots: 25 Roots: 26 Version: 30 About: "Contains a Tool for calculating correlation coefficients for fields in tables or themes." CanUnloadScript: 27 UnloadScript: 28 InstallScript: 29 UninstallScript: 30 ExtVersion: 1 ) (Butn.2 InternalName: "Corr" Help: "Correlation Coefficient//Shows a dialog that calculates correlation coefficients for pairs of attributes in your table" Update: "Corr.ShowUpdate" Icon: 3 Click: "Corr.Show" ) (AVIcon.3 Name: "C" Res: "Icons.C" ) (Butn.4 InternalName: "Corr" Help: "Correlation Coefficient//Shows a dialog that calculates correlation coefficients for pairs of attributes in your active theme" Update: "Corr.ShowUpdate" Icon: 3 Click: "Corr.Show" ) (AVDLog.5 Name: "Correlation" X: 25 Y: 58 W: 309 H: 318 ConstrainedControlNames: 6 Constraints: 7 Server: 8 ControlPanel: 9 Title: "Correlation Coefficient" EscapeEnabled: 1 Modal: 1 AlwaysOnTop: 1 HasTitleBar: 1 Closeable: 1 Open: "Corr.Open" DefaultButton: 21 ) (AVStr.6 S: "OK" ) (Numb.7 N: 85.00000000000000 ) (Nil.8 ) (CPanel.9 Child: 10 Child: 12 Child: 13 Child: 14 Child: 15 ResBox: 16 ResBox: 17 ResBox: 18 ResBox: 19 ResBox: 20 Listening: 1 ) (AVLBox.10 InternalName: "Fields" NextControl: 8 ContentKind: 4 Constraints: 0x55 ColumnCount: 1 HorizontalScroll: 1 Listening: 1 VerticalScroll: 1 Select: "Corr.RunEnable" SelectionStyle: 11 ) (AVEnum.11 Name: "LISTBOX_SELECTION_MULTIRANGE" ) (TextLabel.12 InternalName: "aTextLabel2" Constraints: 0x55 Label: "Generate a correlation coefficient by selecting" Listening: 1 ) (TextLabel.13 InternalName: "aTextLabel3" Constraints: 0x55 Label: "two fields and clicking Run Correlation:" Listening: 1 ) (LButn.14 InternalName: "OK" Help: "A correlation coefficient is a statistic that tellls how much\nalike the distributions of two columns of data are. Specifically\nit checks to see how close each pair of values are to the \nmean for the respective column. The resultant coefficient\nwill be between 0 and 1 where 0 means no correlation exists\nand 1 which denotes exact correlation. //Runs a correlation between the two selected fields" Label: "Run Correlation" Click: "Corr.Run" ) (TextLabel.15 InternalName: "result" Constraints: 0x55 Label: "aTextLabel5" Listening: 1 ) (RectD.16 Left: 17.00000000000000 Top: 240.00000000000000 Right: 295.00000000000000 Bottom: 46.00000000000000 ) (RectD.17 Left: 19.00000000000000 Top: 33.00000000000000 Right: 296.00000000000000 Bottom: 9.00000000000000 ) (RectD.18 Left: 19.00000000000000 Top: 46.00000000000000 Right: 310.00000000000000 Bottom: 26.00000000000000 ) (RectD.19 Left: 18.00000000000000 Top: 278.00000000000000 Right: 138.00000000000000 Bottom: 254.00000000000000 ) (RectD.20 Left: 19.00000000000000 Top: 316.00000000000000 Right: 327.00000000000000 Bottom: 292.00000000000000 ) (Nil.21 ) (Script.22 Name: "Corr.Open" SourceCode: "fl = Self.FindByName(\"Fields\")\ngo = Self.FindByName(\"OK\")\nt = nil\nd = av.GetActiveDoc\nif (d.Is(View)) then\n vt = d.GetActiveThemes.Get(0)\n if (vt.Is(FTheme)) then\n t = vt.GetFTab\n end\nelseif (d.Is(Table)) then\n t = d.GetVTab\nend\n\nif (t = nil) then\n Return nil\nend\n\nff = {}\nfor each f in t.GetFields\n if (f.IsTypeNumber) then\n ff.Add(f.GetAlias)\n end\nend\n\nfl.DefineFromList(ff)\nSelf.FindByName(\"result\").SetLabel(\"The Correlation Coefficient =\")\ngo.SetEnabled(false)" ) (Script.23 Name: "Corr.Run" SourceCode: "d = av.GetActiveDoc\nif (d.Is(View)) then\n vt = d.GetActiveThemes.Get(0)\n if (vt.Is(FTheme)) then\n VDT = vt.GetFTab\n end\nelseif (d.Is(Table)) then\n VDT = d.GetVTab\nend\n\nif (VDT.GetSelection.Count > 0) then\n xx = VDT.GetSelection\n xn = VDT.GetNumSelRecords\nelse\n xx = VDT\n xn = VDT.GetNumRecords\nend\n\nxfield = VDT.FindField(av.FindDialog(\"Correlation\").FindByName(\"Fields\").GetSelection.Get(0))\nyfield = VDT.FindField(av.FindDialog(\"Correlation\").FindByName(\"Fields\").GetSelection.Get(1))\n\ntx = 0\nty = 0 \nfor each r in xx\n tx = tx + VDT.ReturnValueNumber(xfield,r)\n ty = ty + VDT.ReturnvalueNumber(yfield,r)\nend\n\nxm = tx/xn\nym = ty/xn\n\nv = 0\nvs1 = 0\nvs2 = 0\nfor each r in xx\n x1 = VDT.ReturnValueNumber(xfield,r)\n y1 = VDT.ReturnvalueNumber(yfield,r)\n v = v + ((ym - y1)*(xm - x1))\n vs1 = vs1 + ((ym - y1)*(ym - y1))\n vs2 = vs2 + ((xm - x1)*(xm - x1))\nend\n\nd = (vs1*vs2).Sqrt\nRs = v/d\nRs.SetFormat(\"d.ddd\")\nav.FindDialog(\"Correlation\").FindByName(\"result\").SetLabel(\"The Correlation Coefficient = \"+Rs.AsStrin g)\n" ) (Script.24 Name: "Corr.RunEnable" SourceCode: "b = (Self.GetSelection.Count = 2)\nself.GetDialog.FindByName(\"OK\").SetEnabled(b)\n" ) (Script.25 Name: "Corr.Show" SourceCode: "av.FindDialog(\"Correlation\").Open" ) (Script.26 Name: "Corr.ShowUpdate" SourceCode: "t = nil\nd = av.GetActiveDoc\nif (d.Is(View)) then\n vt = d.GetActiveThemes.Get(0)\n if (vt.Is(FTheme)) then\n t = vt.GetFTab\n end\nelseif (d.Is(Table)) then\n t = d.GetVTab\nend\n\nif (t = nil) then\n Self.SetEnabled(false)\n Return nil\nend\n\nff = {}\nfor each f in t.GetFields\n if (f.IsTypeNumber) then\n ff.Add(f.GetAlias)\n end\nend\n\nSelf.SetEnabled( (ff.Count >= 2) )\n " ) (Script.27 Name: "Corr.CanUnload" SourceCode: "return (true)" ) (Script.28 Name: "Corr.Unload" SourceCode: "Dialog.DetachFromExtension(self)" ) (Script.29 Name: "Corr.Install" SourceCode: "if (av.getproject=nil) then return nil end\n\nif(Self.GetPreferences.Get(\"Loaded\") = true) then\n return nil\nend\n\ntheTableGUI = av.GetProject.FindGUI(\"Table\")\ntheViewGUI = av.GetProject.FindGUI(\"View\")\n\nif (theTableGUI = nil) then\n listOfTableGUIs = av.GetProject.FindGUIsFor(Table)\n TableGUIs2Use = Msgbox.MultiList(listOfTableGUIs,\"Choose one or more Table document types to add correlation buttons to:\",\"Extension Loading\")\nelse\n TableGUIs2Use = {theTableGUI}\nend\n\nif (theViewGUI = nil) then\n listOfViewGUIs = av.GetProject.FindGUIsFor(View)\n ViewGUIs2Use = Msgbox.MultiList(listOfViewGUIs,\"Choose one or more View document types to add correlation buttons to:\",\"Extension Loading\")\nelse\n ViewGUIs2Use = {theViewGUI}\nend\n\nH = false\nif (TableGUIs2Use.Count > 0) then\n for each TableDocGUI in TableGUIs2Use\n Bidx = TableDocGUI.GetButtonBar.GetControls.Count - 1\n TableDocGUI.GetButtonBar.Add(Self.Get(0).Clone, Bidx)\n TableDocGUI.SetModified(true)\n end\n H = true\nend \nif (ViewGUIs2Use.Count > 0) then\n for each ViewDocGUI in ViewGUIs2Use\n Bidx = ViewDocGUI.GetButtonBar.GetControls.Count - 1\n ViewDocGUI.GetButtonBar.Add(Self.Get(1).Clone, Bidx)\n ViewDocGUI.SetModified(true)\n end\n H = true\nend\n\nif (H) then\n Self.GetPreferences.Set(\"Loaded\",true)\n Self.GetPreferences.Set(\"Version\",(1))\n av.GetProject.SetModified(true)\nelse\n Msgbox.Error(\"The correlation Tool could not be installed, your project has not been modified\",\"\")\nend\n\n" ) (Script.30 Name: "Corr.Uninstall" SourceCode: "if (av.GetProject = nil) then\n return nil\nend\n\nif (av.GetProject.IsClosing) then\n return nil\nend\n\nlistOfViewGUIs = av.GetProject.FindGUIsFor(View)\nfor each aDocGUI in (listOfViewGUIs)\n c1 = aDocGUI.GetButtonBar.FindByScript(\"Corr.Show\")\n if (c1 <> nil) then\n aDocGUI.GetButtonBar.Remove(c1)\n end\nend\n\n\nlistOfTableGUIs = av.GetProject.FindGUIsFor(Table)\nfor each aDocGUI in (listOfTableGUIs)\n c1 = aDocGUI.GetButtonBar.FindByScript(\"Corr.Show\")\n if (c1 <> nil) then\n aDocGUI.GetButtonBar.Remove(c1)\n end\nend\n\n\n\nav.getproject.setmodified(true)\n\n" )