/3.2 (Extension.1 Name: "DMS to DD Conversion" FirstRootClassName: "List" Roots: 2 Roots: 3 Roots: 4 Roots: 12 Roots: 13 Version: 32 About: "Converts DMS (format: ddd mm ss) to Decimal Degrees (format: ddd.dddddd) and creates two new fields in the table" InstallScript: 14 UninstallScript: 15 ExtVersion: 1 ) (List.2 ) (List.3 ) (List.4 Child: 5 ) (List.5 Child: 6 Child: 10 Child: 11 ) (List.6 Child: 7 Child: 8 Child: 9 ) (AVStr.7 S: "Table" ) (AVStr.8 S: "Table" ) (AVStr.9 S: "DMS.DMS_2_DD" ) (Choice.10 Help: "Converts DMS to DD and creates new fields, DD-X and DD-Y, in the table." Label: "Convert DMS to DD" Click: "DMS.DMS_2_DD" Shortcut: "Keys.None" ) (Numb.11 N: 17.00000000000000 ) (List.12 ) (Script.13 Name: "DMS.DMS_2_DD" SourceCode: "'Name: DMS.DMS_2_DD\n'File Name: dms2dd.ave\n'Version: a\n'Date: 9/29/00\n'Created by: Rosemary Neal\n'Written to File as: dms2dda.ave\n\n'Converts DegreesMinutesSeconds values to DecimalDegrees\n'Modified from an anonymous user.\n\nnewfieldnameList = {\"DD-Y\", \"DD-X\"}\n'**********************************************\n\n\n'Get the list of tables in the project and let the user pick one\ntabList = {}\nfor each i in av.GetProject.GetDocs\n if (i.Is(Table)) then\n tabList.Add(i)\n end \nend\n\n'Have the user pick the table to conv ert\ntb = MsgBox.ChoiceAsString(tabList,\n \"Choose the table which contains the values to convert:\",\n \"Convert DMS values to DD\")\nif (tb = Nil) then\n return \"\"\nend\ntbv = tb.GetVTab\nflist = {}\n\n'Have the user pick the field with the Lattitude DMS values\nf1 = MsgBox.ChoiceAsString(tbv.GetFields,\n \"Choose the field to convert from Lattitude DMS to Lattitude DD\",\n \"Select Lattitude field\")\nif (f1 = Nil) then\n return \"\"\nend\nflist.add(f1)\n\n'Have the user pick the field with the Longitude DMS values\nf2 = MsgBo x.ChoiceAsString(tbv.GetFields,\n \"Choose the field to convert from Longitude DMS to Longitude DD\",\n \"Select Longitude field\")\nif (f2 = Nil) then\n return \"\"\nend\nflist.add(f2)\n\nn = 0\nfor each f in flist\n if (n = 0) then\n newFieldname = newfieldnameList.Get(0)\n else\n newfieldname = newfieldnameList.Get(1)\n end\n'Make sure you can write to the table, and that the field doesn't already exist\n if (tbv.CanEdit.Not) then\n MsgBox.Info(\"Cannot edit the table.\",\"Convert DMS values to DD\")\n return \"\"\n end\n if (tb v.FindField(newFieldName).Is(Field)) then\n MsgBox.Info(\"A field with name\"++newFieldName.asString++\n \"already exists.\",\"Convert DMS values to DD\")\n return \"\"\n end\n\n'Add the new field\ntbv.SetEditable(true)\nnewf = Field.Make(newFieldName,#FIELD_DECIMAL,12,6)\ntbv.AddFields({newf})\n\n'Convert DMS to DD\n for each r in tbv\n v = tbv.ReturnValueString(f, r)\n ' split the string into 3 parts: D M S\n it = v.AsTokens(\" \")\n if (it.Count <> 3) then\n MsgBox.Info(\"Values in field\"++f.asString++\n \"appear to be in the incorrect format. Need DDD MM SS.\",\n \"Convert DMS to DD\")\n tbv.RemoveFields({newf}) \n tbv.SetEditable(false)\n return \"\"\n end\n \n ' Do the conversion\n ' degrees = degrees\n d = it.Get(0)\n ' minutes/60\n m = ((it.Get(1).asNumber) / 60)\n ' seconds/3600\n s = ((it.Get(2).asNumber) / 3600)\n ms = (m + s)\n if (ms <> 0) then\n ms.SetFormat(\"dd.dddddd\")\n ms = ms.asString.asTokens(\".\").Get(1)\n end\n dms = (d + \".\" + ms.asString).asNumber\n\n dms.SetFormat(\"dd.dddddd\")\n tb v.SetValueNumber(newf,r,dms)\n end\n n = n+1\nend\n\n' Stop editing the table\ntbv.SetEditable(false)\n\n\n\n" ) (Script.14 Name: "DMS.ExtensionInstall" SourceCode: "'Script Name: DMS.ExtensionInstall\n'File Name: extinst.ave\n'Version: a\n'Date: 9/29/00\n'Created by Rosemary Neal\n'Written to Disk as: extinsta.ave\n\n'**********************************************************************\n'The SELF is the Extension\n'**********************************************************************\n\n'DO NOT EDIT!!!\n\nif (av.getproject=nil) then return(nil) end\n\n\ntheDocs = SELF.get(0)\ntheControlList = SELF.get(1)\ntheMenuList = SELF.get(2)\ntheToolMenuList=SELF.Get(3)\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'\nfor each totalControl in theControlList\n 'The Control list\n acontrol=totalControl.get(0)\n \n 'The physical control\n theControl = totalControl.get(1)\n \n 'The control Index\n theCindex=totalControl.get(2)\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(\"\")\n \n 'Add the control to the control set\n theControlSet.Add(theControl,theCindex)\nend\n\n\n'Add the menus\nfor each totalcontrol in theMenuList\n \n 'The Control list\n acontrol=totalControl.get(0)\n mDoc=acontrol.get(0)\n mMenu=acontrol.get(1)\n mMenuItem=acontr ol.get(2)\n\n 'The physical control\n theControl = totalControl.get(1)\n \n 'The control Index\n theCindex=totalControl.get(2)\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 theMbar=av.getproject.findGUI(mDoc).GetMenuBar\n themenu=theMbar.findbylabel(mMenu)\n if (themenu=NiL) then\n themenu=menu. make\n themenu.setlabel(mMenu)\n theMbar.add(themenu,999)\n end\n \n themenu.add(thecontrol, theCindex)\nend\n \n \n'Add the Tool Menus\n\nfor each totalControl in theToolMenuList\n 'The Control list\n acontrol=totalControl.get(0)\n \n 'The physical control\n theControl = totalControl.get(1)\n \n 'The control Index\n theCindex=totalControl.get(2)\n\n 'Find the DocGUI\n theControlDoc=av.getproject.findGUI(aControl.get(0))\n if (theControlDoc=NIL) then \n MsgBox.Warning(\"The GUI \"+aCo ntrol.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=av.getproject.findGUI(aControl.get(0)).GetToolBar\n \n 'Add the control to the control set\n theControlSet.Add(theControl,theCindex)\nend\n\n\nav.getproject.setmodified(true)\n\n\n'And the scripts add themselves\n\n" ) (Script.15 Name: "DMS.ExtensionUninstall" SourceCode: "'Script Name: DMS.ExtensionUninstall\n'File Name: extunin.ave\n'Version: a\n'Date: 9/29/00\n'Created by Rosemary Neal\n'Written to Disk as: extunina.ave\n\n'****************************************************************\n'The SELF is the Extension\n'****************************************************************\n\n\n'DO NOT EDIT!!!\n\n'The SELF is the Extension\n\ntheDocs = SELF.get(0)\ntheControlList = SELF.get(1)\ntheMenuList = SELF.get(2)\ntheToolMenuList=SELF.get(3)\ntheProject=Av.getproject\n\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 totalControl 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 fo r 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 sequence 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(\"\")\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 (thecontrol = \"ToolBar\") then\n theControlSet.selectdefault\n end\n end\nend\n\n\n'Remove the Menus\n'\nfor each totalcontrol in theMenuList\n \n 'The Control list\n acontrol=totalControl.get(0)\n mDoc=acontrol.get(0)\n mMenu=acontrol.get(1)\n mMenuItem=acontrol.get(2)\n\n 'The physical control\n theControl = totalControl.get(1)\n \n 'The control Index\n theCindex=totalControl .get(2)\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 theMbar=av.getproject.findGUI(mDoc).GetMenuBar\n themenu=theMbar.findbylabel(mMenu)\n if (themenu=NiL) then\n MsgBox.Warning(\"The menu named \"+mMenu+\" is not here.\",\"Script Eror\")\n 'return(nil)\n else\n \n thething=themenu.getcontrols.fin d(thecontrol)\n if (thething<>NIL) then \n themenu.remove(thecontrol) \n end\n 'msgbox.info(themenu.GetControls.count.asstring,\"\")\n if (themenu.GetControls.count<1) then\n theMbar.remove(themenu)\n end\n end\nend\n \nfor each totalControl in theToolMenuList\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 Cont rol\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 sequence finds the appropiate control set\n thecontrolset=av.getproject.findGUI(aControl.get(0)).GetToolBar\n\n \n 'See if the control is in the set , if so remove it\n if (theControlSet.GetControls.find(theControl)<>NIL) then\n \n theControlSet.remove(theContro l)\n theControlSet.selectdefault\n end\n\nend\n \n\n'And the scripts delete themselves\n\n\nav.getproject.setmodified(true)\n\n" )