/3.2 (Extension.1 Name: "Fuzzy Classification" FirstRootClassName: "List" Roots: 2 Roots: 3 Roots: 12 Roots: 13 Version: 32 About: "Performs fuzzy classification. Built February 16, 2005." InstallScript: 14 UninstallScript: 15 ExtVersion: 1 ) (List.2 ) (List.3 Child: 4 ) (List.4 Child: 5 Child: 10 Child: 9 ) (List.5 Child: 6 Child: 7 Child: 8 Child: 9 ) (AVStr.6 S: "Table" ) (AVStr.7 S: "ButtonBar" ) (AVStr.8 S: "Fuzzy.Main" ) (Numb.9 N: 23.00000000000000 ) (Butn.10 Help: "Fuzzy Classification//Performs a fuzzy classification" Icon: 11 Click: "Fuzzy.Main" ) (AVIcon.11 Name: "F" Res: "Icons.F" ) (Script.12 Name: "Fuzzy.Main" SourceCode: "'Set some constants\n\ndlgTitle = \"Fuzzy Classification\"\n\n\n'Get the list of tables in the project\n\ntableList = Av.GetProject.GetDocsWithGUI(Av.GetProject.FindGUI(\"Table\"))\nif (tableList.Count < 2) then\n MsgBox.Error(\"You need at least two tables loaded into your project.\", dlgTitle)\n return NIL\nend\n\n\n'Get the error matrix table\n\nerrorTable = MsgBox.List(tableList, \"Select the error matrix:\", dlgTitle)\nif (errorTable = NIL) then\n return NIL\nend\nerrorVTab = errorTable.GetVTab\nerrorVTab.RememberSelection\nerro rClassField = errorVTab.FindField(\"Class\")\nif (errorClassField = NIL) then\n errorClassField = MsgBox.List(errorVTab.GetFields, \"Select the class field:\", dlgTitle)\n if (errorClassField = NIL) then\n return NIL\n end\nend\ntableList.RemoveObj(errorTable)\n\n\n'Get the fuzzy classification table\n\nfuzzyTable = MsgBox.List(tableList, \"Select the fuzzy classification table:\", dlgTitle)\nif (fuzzyTable = NIL) then\n return NIL\nend\nfuzzyVTab = fuzzyTable.GetVTab\nfuzzyVTab.RememberSelection\nfuzzyClassField = fuzzyVTa b.FindField(\"Class\")\nif (fuzzyClassField = NIL) then\n fuzzyClassField = MsgBox.List(fuzzyVTab.GetFields, \"Select the class field:\", dlgTitle)\n if (fuzzyClassField = NIL) then\n return NIL\n end\nend\n\n\n'Check to make sure the tables match\n\nif ((fuzzyVTab.GetFields.Count - 1) <> fuzzyVTab.GetNumRecords) then\n MsgBox.Error(\"The number of rows and columns in\" ++ fuzzyTable.GetName ++ \"don't match.\", dlgTitle)\n return NIL\nend\nclassList = List.Make\nselBM = errorVTab.GetSelection.Clone\nfor each aRec in fuzzyV Tab\n className = fuzzyVTab.ReturnValue(fuzzyClassField, aRec)\n classList.Add(className)\n if (fuzzyVTab.FindField(className) = NIL) then\n MsgBox.Error(\"Field\" ++ className ++ \"not found in\" ++ fuzzyTable.GetName + \".\", dlgTitle)\n return NIL\n end\n if (errorVTab.FindField(className) = NIL) then\n MsgBox.Error(\"Field\" ++ className ++ \"not found in\" ++ errorTable.GetName + \".\", dlgTitle)\n return NIL\n end\n errorVTab.Query(\"[\" + errorClassField.GetName + \"] =\" ++ className.Quote, selBM, #VTAB_SEL TYPE_NEW)\n if (selBM.Count = 0) then\n MsgBox.Error(\"Class\" ++ className ++ \"not found in\" ++ errorTable.GetName + \".\", dlgTitle)\n return NIL\n end\nend\n\n\n'Make filenames for new tables\n\nbaseFN = errorVTab.GetBaseTableFileName\nlevel4FN = baseFN.AsString.Substitute(\".\" + baseFN.GetExtension, \"_f4.dbf\").AsFileName\nif (File.Exists(level4FN)) then\n level4FN = FileDialog.Put(level4FN, \"*.dbf\", \"Save Level 4 Table As...\")\n if (level4FN = NIL) then\n return NIL\n end\nend\nlevel3FN = baseFN.AsString.Substit ute(\".\" + baseFN.GetExtension, \"_f3.dbf\").AsFileName\nif (File.Exists(level3FN)) then\n level3FN = FileDialog.Put(level3FN, \"*.dbf\", \"Save Level 3 Table As...\")\n if (level3FN = NIL) then\n return NIL\n end\nend\nlevel2FN = baseFN.AsString.Substitute(\".\" + baseFN.GetExtension, \"_f2.dbf\").AsFileName\nif (File.Exists(level2FN)) then\n level2FN = FileDialog.Put(level2FN, \"*.dbf\", \"Save Level 2 Table As...\")\n if (level2FN = NIL) then\n return NIL\n end\nend\n\n\n'Make the level 4 table\n\nerrorVTab.Export(level4FN, dBASE, FALSE)\nlevel4VTab = VTab.Make(level4FN, TRUE, FALSE)\nlevel4BM = level4VTab.GetSelection\nclassField = level4VTab.FindField(errorClassField.GetName)\nfor each aRec in level4VTab\n className = level4VTab.ReturnValue(classField, aRec)\n if (classList.FindByValue(className) = -1) then\n level4BM.Set(aRec)\n end\nend\nlevel4VTab.RemoveRecords(level4BM)\nfieldList = level4VTab.GetFields.Clone\nfieldList.RemoveObj(classField)\nfor each aField in fieldList\n if (classList.FindByValue(aField.GetName) = -1) then\n level4VTab.RemoveFields({aField})\n end\nend\ntotalField = Field.Make(\"Total\", #FIELD_LONG, 6, 0)\npercentField = Field.Make(\"Percent\", #FIELD_FLOAT, 6, 3)\nlevel4VTab.AddFields({totalField, percentField})\ntotalRec = level4VTab.AddRecord\nlevel4VTab.SetValue(classField, totalRec, \"Total\")\ntotalStr = level4VTab.ReturnValue(classField, totalRec)\npercentRec = level4VTab.AddRecord\nlevel4VTab.SetValue(classField, percentRec, \"Percent\")\npercentStr = level4VTab.ReturnValue(classField, percentRec)\n\n\n'Update the level 4 table\n\nAv.Run(\"Fuzzy.UpdateTable\", {level4VTab, classField, fuzzyVTab, fuzzyClassField, classList, 4, \n totalField, percentField, totalRec, percentRec})\nlevel4VTab.GetSelection.ClearAll\nlevel4VTab.SetEditable(FALSE)\nlevel4Table = Table.Make(level4VTab)\nlevel4Table.SetName(level4FN.GetBaseName)\n\n\n'Make and update the level 3 table\n\nlevel4VTab.Export(level3FN, dBASE, FALSE)\nlevel3VTab = VTab.Make(level3FN, TRUE, FALSE)\nlevel3BM = level3VTab.GetSelection\nclassField = level3VTab.FindField(errorClassField.Get Name)\ntotalField = level3VTab.FindField(\"Total\")\npercentField = level3VTab.FindField(\"Percent\")\nlevel3VTab.Query(\"[\" + classField.GetName + \"] =\" ++ totalStr.Quote, level3BM, #VTAB_SELTYPE_NEW)\ntotalRec = level3BM.GetNextSet(-1)\nlevel3VTab.Query(\"[\" + classField.GetName + \"] =\" ++ percentStr.Quote, level3BM, #VTAB_SELTYPE_NEW)\npercentRec = level3BM.GetNextSet(-1)\nAv.Run(\"Fuzzy.UpdateTable\", {level3VTab, classField, fuzzyVTab, fuzzyClassField, classList, 3, \n totalField, percentField, totalRec, percentRec}) \nlevel3VTab.GetSelection.ClearAll\nlevel3VTab.SetEditable(FALSE)\nlevel3Table = Table.Make(level3VTab)\nlevel3Table.SetName(level3FN.GetBaseName)\n\n\n'Make and update the level 2 table\n\nlevel3VTab.Export(level2FN, dBASE, FALSE)\nlevel2VTab = VTab.Make(level2FN, TRUE, FALSE)\nlevel2BM = level2VTab.GetSelection\nclassField = level2VTab.FindField(errorClassField.GetName)\ntotalField = level2VTab.FindField(\"Total\")\npercentField = level2VTab.FindField(\"Percent\")\nlevel2VTab.Query(\"[\" + classField.GetName + \"] =\" ++ totalS tr.Quote, level2BM, #VTAB_SELTYPE_NEW)\ntotalRec = level2BM.GetNextSet(-1)\nlevel2VTab.Query(\"[\" + classField.GetName + \"] =\" ++ percentStr.Quote, level2BM, #VTAB_SELTYPE_NEW)\npercentRec = level2BM.GetNextSet(-1)\nAv.Run(\"Fuzzy.UpdateTable\", {level2VTab, classField, fuzzyVTab, fuzzyClassField, classList, 2, \n totalField, percentField, totalRec, percentRec})\nlevel2VTab.GetSelection.ClearAll\nlevel2VTab.SetEditable(FALSE)\nlevel2Table = Table.Make(level2VTab)\nlevel2Table.SetName(level2FN.GetBaseName)\n\n\n'Restore s elections\n\nerrorVTab.SetSelection(errorVTab.GetLastSelection)\nerrorVTab.UpdateSelection\nfuzzyVTab.SetSelection(fuzzyVTab.GetLastSelection)\nfuzzyVTab.UpdateSelection\n" ) (Script.13 Name: "Fuzzy.UpdateTable" SourceCode: "'Get passed parameters\n\nerrorVTab = SELF.Get(0)\nerrorClassField = SELF.Get(1)\nfuzzyVTab = SELF.Get(2)\nfuzzyClassField = SELF.Get(3)\nclassList = SELF.Get(4)\nlevel = SELF.Get(5)\ntotalField = SELF.Get(6)\npercentField = SELF.Get(7)\ntotalRec = SELF.Get(8)\npercentRec = SELF.Get(9)\n\n\n'Set up dictionaries to keep track of statistics\n\nrowDict = Dictionary.Make(classList.Count)\ncorrectDict = Dictionary.Make(classList.Count)\nfor each className in classList\n rowDict.Set(className, 0)\nend\n\n\n'Move numbers around accordi ng to fuzzy level\n\nfuzzyBM = fuzzyVTab.GetSelection\nerrorBM = errorVTab.GetSelection\nerrorVTab.Calculate(\"0\", totalField)\nerrorVTab.Calculate(\"0\", percentField)\nfor each className in classList\n numClose = 0\n currentClassField = errorVTab.FindField(className)\n errorVTab.SetValue(currentClassField, totalRec, 0)\n errorVTab.SetValue(currentClassField, percentRec, 0)\n fuzzyVTab.Query(\"[\" + className + \"] =\" ++ level.AsString, fuzzyBM, #VTAB_SELTYPE_NEW)\n for each aRec in fuzzyBM\n closeClassName = fuzzyV Tab.ReturnValue(fuzzyClassField, aRec)\n errorVTab.Query(\"[\" + errorClassField.GetName + \"] =\" ++ closeClassName.Quote, errorBM, #VTAB_SELTYPE_NEW)\n closeRec = errorBM.GetNextSet(-1)\n numClose = numClose + errorVTab.ReturnValue(currentClassField, closeRec)\n errorVTab.SetValue(currentClassField, closeRec, 0)\n end\n errorVTab.Query(\"[\" + errorClassField.GetName + \"] =\" ++ className.Quote, errorBM, #VTAB_SELTYPE_NEW)\n correctRec = errorBM.GetNextSet(-1)\n numCorrect = errorVTab.ReturnValue(current ClassField, correctRec) + numClose\n errorVTab.SetValue(currentClassField, correctRec, numCorrect)\n correctDict.Set(className, numCorrect)\nend\n\n\n'Calculate totals and percentages\n\ngrandTotal = 0\ntotalCorrect = 0\nfor each className in classList\n columnTotal = 0\n currentClassField = errorVTab.FindField(className)\n errorVTab.Query(\"[\" + className + \"] > 0\", errorBM, #VTAB_SELTYPE_NEW)\n for each aRec in errorVTab.GetSelection\n currentClassName = errorVTab.ReturnValue(errorClassField, aRec)\n currentCo unt = errorVTab.ReturnValue(currentClassField, aRec)\n columnTotal = columnTotal + currentCount\n rowDict.Set(currentClassName, rowDict.Get(currentClassName) + currentCount)\n end\n errorVTab.SetValue(currentClassField, totalRec, columnTotal)\n errorVTab.SetValue(currentClassField, percentRec, correctDict.Get(className) / columnTotal)\n grandTotal = grandTotal + columnTotal\n totalCorrect = totalCorrect + correctDict.Get(className)\nend\nerrorVTab.SetValue(totalField, totalRec, grandTotal)\nerrorVTab.SetVa lue(percentField, percentRec, totalCorrect / grandTotal)\nfor each aRec in errorVTab\n if ((aRec <> totalRec) and (aRec <> percentRec)) then\n className = errorVTab.ReturnValue(errorClassField, aRec)\n errorVTab.SetValue(totalField, aRec, rowDict.Get(className))\n errorVTab.SetValue(percentField, aRec, correctDict.Get(className) / rowDict.Get(className))\n end\nend\n" ) (Script.14 Name: "Ext.UserExtInstall" SourceCode: "' Ext.UserExtInstall Thad Tilton\n' A generic install script for new extensions made with the ExtBuilder dialog\n' \n\nif (av.getproject=nil) then return(nil) end\n\n\ntheDocs = SELF.get(0)\ntheControlList = SELF.get(1)\ntheProject=Av.getproject\n\n\n'Add the Docs\n'\nfor each adoc in theDocs\n theProject.addDoc(adoc)\nend\n\n'Add the Controls\n' ' totalControl =\nfor each totalControl in theControlList '{ {\"GUI\",\"BBar\",Scpt\"}, control, idx#}\n 'The Control list\n acontrol=tot alControl.get(0) '{\"GUI\",\"BBar\",\"Script\"}\n \n 'The physical control\n theControl = totalControl.get(1) ' UserControl\n \n 'The control Index\n theCindex=totalControl.get(2) ' Index#\n\n 'Find the DocGUI\n theControlDoc=av.getproject.findGUI(aControl.get(0))\n if (theControlDoc=NIL) then \n MsgBox.Warning(\"The GUI \"+aControl.get(0)+\" cannot be found in the current project.\",\"Script Eror\")\n return(nil)\n end\n \n 'This finds the control set \n thecommand=\"av.getproject.findGUI(\" \"\"+aControl.get(0)+\"\"\").Get\"+acontrol.get(1)\n thescript1=Script.Make(thecommand)\n thecontrolset=thescript1.doit(\"\") '** = av.GetProject.FindGUI(\"View\").GetButtonBar **\n \n 'Add the control to the control set\n theControlSet.Add(theControl,theCindex)\nend\n\nav.getproject.setmodified(true)" ) (Script.15 Name: "Ext.UserExtUnInstall" SourceCode: "'Ext.UserExt.UnInstall Thad Tilton\n'A generic uninstall script for an extension made with the ExtBuilder dialog\n\n'SELF is the Extension\n\ntheDocs = SELF.get(0)\ntheControlList = SELF.get(1)\ntheProject=Av.getproject\n\n'Add the Docs\n'\nfor each adoc in theDocs\n If (theProject.finddoc(adoc.getname)<>NIL) then \n theAnswer=msgbox.yesno(\"Remove the Document \"+adoc.getname+\"?\",\"Remove Document?\",TRUE)\n if (theAnswer=TRUE) then theProject.RemoveDoc(adoc) end\n end\nend\n\n'Removethe Controls\n'\nfor each to talControl in theControlList\n 'Get the control list from the Ext\n acontrol=totalControl.get(0)\n \n 'Get the physical Control\n theControl = totalControl.get(1)\n \n 'Get the Controls Index\n theCindex=totalControl.get(2)\n\n 'Find the DocGUI for the Control\n theControlDoc=av.getproject.findGUI(aControl.get(0))\n if (theControlDoc=NIL) then \n MsgBox.Warning(\"The GUI \"+aControl.get(0)+\" cannot be found in the current project.\",\"Script Eror\")\n return(nil)\n end\n \n 'This seq uence finds the appropiate control set\n thecommand=\"av.getproject.findGUI(\"\"\"+aControl.get(0)+\"\"\").Get\"+acontrol.get(1)\n thescript1=Script.Make(thecommand)\n thecontrolset=thescript1.doit(\"\") '**>> av.GetProject.FindGUI(\"View\").GetButtonBar, e.g.\n\n 'See if the control is in the set , if so remove it\n if (theControlSet.GetControls.find(theControl)<>NIL) then\n theControlSet.remove(theControl)\n if (acontrol.get(1) = \"ToolBar\") then\n theControlSet.selectdefault\n end\n end\nend \n\nav.getproject.setmodified(true)\n" )