/3.0 (Extension.1 Name: "Hydrologic Modeling v1.1 (sample)" Dependencies: "$AVEXT/spatial.avx\n$AVBIN/avdlog.dll\n" FirstRootClassName: "List" Roots: 2 Roots: 27 Roots: 81 Roots: 82 Roots: 83 Roots: 84 Roots: 85 Roots: 86 Roots: 87 Roots: 88 Roots: 89 Roots: 90 Roots: 91 Roots: 92 Roots: 93 Roots: 94 Roots: 95 Roots: 96 Roots: 97 Roots: 98 Roots: 99 Roots: 100 Roots: 101 Roots: 102 Roots: 103 Roots: 104 Roots: 105 Roots: 106 Roots: 107 Roots: 108 Roots: 109 Roots: 110 Roots: 111 Roots: 112 Roots: 113 Roots: 114 Roots: 115 Roots: 116 Roots: 117 Roots: 118 Roots: 119 Roots: 120 Roots: 121 Roots: 122 Roots: 123 Roots: 124 Roots: 125 Roots: 126 Roots: 127 Roots: 128 Roots: 129 Roots: 130 Roots: 131 Roots: 132 Roots: 133 Roots: 134 Roots: 135 Roots: 136 Roots: 137 Roots: 138 Roots: 139 Roots: 140 Roots: 141 Version: 30 About: "Extends the Spatial Analyst to support hydrologic modeling (v1.1)." UnloadScript: 140 InstallScript: 142 UninstallScript: 143 ExtVersion: 1100 ) (List.2 Child: 3 ) (PMenu.3 InternalName: "Hydro" Child: 4 Child: 5 Child: 6 Child: 7 Child: 8 Child: 9 Child: 10 Child: 11 Child: 12 Child: 13 Child: 14 Child: 15 Child: 16 Child: 17 Child: 18 Child: 19 Child: 20 Child: 21 Child: 22 Child: 23 Child: 24 Child: 25 Child: 26 Label: "H&ydro" ) (Choice.4 Disabled: 1 Help: "Displays the dialog box for creating watersheds and their characteristics for input to a hydrologic model. (Active Theme: Elevation Grid)" Update: "Spatial.HasGridThemeUpdate" Label: "&Hydrologic Modeling" Click: "Hydro.dd.Startup" Shortcut: "Keys.None" ) (Space.5 ) (Choice.6 Disabled: 1 Help: "Computes flow direction. (ActiveTheme: Elevation Grid)" Update: "Hydro.OneActiveGridUpdate" Label: "Flow &Direction" Click: "Hydro.FlowDirection" Shortcut: "Keys.None" ) (Choice.7 Disabled: 1 Help: "Identifies sinks. (Active Theme: Flow Direction Grid)" Update: "Hydro.OneActiveIntGridUpdate" Label: "Identify &Sinks" Click: "Hydro.IdentifySinks" Shortcut: "Keys.None" ) (Choice.8 Disabled: 1 Help: "Fills sinks in an elevation grid theme. (Active Theme: Elevation Grid)" Update: "Hydro.OneActiveGridUpdate" Label: "Fill sin&ks" Click: "Hydro.Fill" Shortcut: "Keys.None" ) (Choice.9 Disabled: 1 Help: "Calculates the flow accumulation for each cell. (Active Theme: Flow Direction)" Update: "Hydro.OneActiveIntGridUpdate" Label: "Flow &Accumulation" Click: "Hydro.FlowAccumulation" Shortcut: "Keys.None" ) (Space.10 ) (Choice.11 Disabled: 1 Help: "Delineates watersheds. (Active Theme: Flow Accumulation Grid)" Update: "Hydro.OneActiveGridUpdate" Label: "&Watershed" Click: "Hydro.Watershed" Shortcut: "Keys.None" ) (Choice.12 Disabled: 1 Help: "Calculates area of each watershed. (Active Theme: Watershed Grid)" Update: "Hydro.OneActiveIntGridUpdate" Label: "A&rea" Click: "Hydro.CalculateArea" Shortcut: "Keys.None" ) (Choice.13 Disabled: 1 Help: "Calculates perimeter of each watershed. (Active Theme: Watershed Grid)" Update: "Hydro.OneActiveIntGridUpdate" Label: "Peri&meter" Click: "Hydro.CalculatePerimeter" Shortcut: "Keys.None" ) (Choice.14 Disabled: 1 Help: "Calculates length from pour point to the furthest perimeter point for each watershed. (Active Theme: Watershed Grid)" Update: "Hydro.OneActiveIntGridUpdate" Label: "Len>h" Click: "Hydro.BasinLength" Shortcut: "Keys.None" ) (Choice.15 Disabled: 1 Help: "Calculates flow distance to pour point or perimeter for each cell. (Active Theme: Flow Direction Grid)" Update: "Hydro.OneActiveIntGridUpdate" Label: "Flow &Length" Click: "Hydro.FlowLength" Shortcut: "Keys.None" ) (Choice.16 Disabled: 1 Help: "Calculates maximum flow distance for each watershed. (Active Theme: Watershed Grid)" Update: "Hydro.OneActiveGridUpdate" Label: "Flow Length by Watershed" Click: "Hydro.FlowDistance" Shortcut: "Keys.None" ) (Choice.17 Disabled: 1 Help: "Length squared divided by area (ie: Length = Max distance between the pourpoint and perimeter). (Active Theme: Watershed Grid)" Update: "Hydro.OneActiveGridUpdate" Label: "Shape &Factor by Watershed" Click: "Hydro.ShapeFactor" Shortcut: "Keys.None" ) (Space.18 ) (Choice.19 Disabled: 1 Help: "Creates a stream network. (Active Theme: Flow Accumulation Grid)" Update: "Hydro.OneActiveGridUpdate" Label: "Stream &Network as Line Shape" Click: "Hydro.StreamNetwork" Shortcut: "Keys.None" ) (Choice.20 Disabled: 1 Help: "Calculates the centroid of a watershed. (Active Theme: Watershed Grid)" Update: "Hydro.OneActiveIntGridUpdate" Label: "&Centroid as Point Shape" Click: "Hydro.Centroid" Shortcut: "Keys.None" ) (Choice.21 Disabled: 1 Help: "Creates a shapefile of watershed pour points. (Active Theme: Watershed Grid)" Update: "Hydro.OneActiveIntGridUpdate" Label: "Pour Poin&ts as Point Shape" Click: "Hydro.PourPoint" Shortcut: "Keys.None" ) (Space.22 ) (Choice.23 Disabled: 1 Help: "Calculates the mean elevation for each watershed. (Active Theme: Watershed Grid)" Update: "Hydro.OneActiveIntGridUpdate" Label: "Mean &Elevation" Click: "Hydro.MeanElevation" Shortcut: "Keys.None" ) (Choice.24 Disabled: 1 Help: "Calculates the mean slope for each watershed. (Active Theme: Watershed Grid)" Update: "Hydro.OneActiveIntGridUpdate" Label: "Mean Sl&ope" Click: "Hydro.MeanSlope" Shortcut: "Keys.None" ) (Choice.25 Disabled: 1 Help: "Calculates the mean precipitation for each watershed. (Active Theme: Watershed Grid)" Update: "Hydro.OneActiveIntGridUpdate" Label: "Mean &Precipitation" Click: "Hydro.MeanPrecipitation" Shortcut: "Keys.None" ) (Choice.26 Disabled: 1 Help: "Calculates the mean curve number for each watershed. (Active Theme: Watershed Grid)" Update: "Hydro.OneActiveIntGridUpdate" Label: "Mean Cur&ve Number" Click: "Hydro.CurveNumber" Shortcut: "Keys.None" ) (AVDLog.27 Name: "Hydro" X: 64 Y: 71 W: 442 H: 325 DocActivate: "Hydro.dd.Activate" ConstrainedControlNames: 28 ConstrainedControlNames: 29 ConstrainedControlNames: 30 ConstrainedControlNames: 31 Constraints: 32 Constraints: 33 Constraints: 34 Constraints: 35 Server: 36 ControlPanel: 37 Title: "Hydrologic Modeling" EscapeEnabled: 1 AlwaysOnTop: 1 HasTitleBar: 1 Closeable: 1 Open: "Hydro.dd.Open" DefaultButton: 80 ) (AVStr.28 S: "aLabelButton4" ) (AVStr.29 S: "aLabelButton19" ) (AVStr.30 S: "btn_OK" ) (AVStr.31 S: "aLabelButton36" ) (Numb.32 N: 85.00000000000000 ) (Numb.33 N: 85.00000000000000 ) (Numb.34 N: 85.00000000000000 ) (Numb.35 N: 85.00000000000000 ) (Nil.36 ) (CPanel.37 Child: 38 Child: 39 Child: 40 Child: 41 Child: 42 Child: 43 Child: 44 Child: 45 Child: 46 Child: 47 Child: 48 Child: 49 Child: 50 Child: 51 Child: 52 Child: 53 Child: 54 Child: 55 Child: 56 Child: 57 Child: 58 ResBox: 59 ResBox: 60 ResBox: 61 ResBox: 62 ResBox: 63 ResBox: 64 ResBox: 65 ResBox: 66 ResBox: 67 ResBox: 68 ResBox: 69 ResBox: 70 ResBox: 71 ResBox: 72 ResBox: 73 ResBox: 74 ResBox: 75 ResBox: 76 ResBox: 77 ResBox: 78 ResBox: 79 ) (LButn.38 InternalName: "aLabelButton4" Label: "Cancel" Click: "Hydro.dd.btn.Click" ) (AVCBBox.39 InternalName: "cbx_Themes" Help: "ComboBox" Update: "Hydro.dd.cbx_Themes.Update" NextControl: 36 ContentKind: 4 Constraints: 0x55 Listening: 1 Label: " " ) (TextLabel.40 InternalName: "lblDEM" Constraints: 0x55 Label: "Select an elevation surface" Listening: 1 ) (TextLabel.41 InternalName: "lblAttribute" Disabled: 1 Constraints: 0x55 Label: "Select watershed attributes" Listening: 1 ) (AVCBox.42 InternalName: "check_OutShape" Disabled: 1 Listening: 1 Label: "Output as shapefile" Constraints: 0x55 ) (LButn.43 InternalName: "aLabelButton19" Label: "Help" Click: "Hydro.dd.Help" ) (LButn.44 InternalName: "btn_OK" Disabled: 1 Update: "Hydro.dd.btn_OK.Update" Label: "OK" Click: "Hydro.dd.btn_OK.Click" ) (LButn.45 InternalName: "aLabelButton36" Disabled: 1 Update: "Hydro.dd.btn_OK.Update" Label: "OK" Click: "Hydro.dd.btn_OK.Click" ) (AVCBox.46 InternalName: "check_area" Disabled: 1 Listening: 1 Label: "Area" Constraints: 0x55 ) (AVCBox.47 InternalName: "check_Perimeter" Disabled: 1 Listening: 1 Label: "Perimeter" Constraints: 0x55 ) (AVCBox.48 InternalName: "check_Centroid" Disabled: 1 Listening: 1 Label: "Centroid" Constraints: 0x55 ) (AVCBox.49 InternalName: "Check_fDist" Disabled: 1 Listening: 1 Label: "Flow Length" Constraints: 0x55 ) (AVCBox.50 InternalName: "check_fLength" Disabled: 1 Listening: 1 Label: "Stream Flow Length" Constraints: 0x55 ) (AVCBox.51 InternalName: "check_wlength" Disabled: 1 Listening: 1 Label: "Length" Constraints: 0x55 ) (AVCBox.52 InternalName: "check_sFactor" Disabled: 1 Listening: 1 Label: "Shape Factor" Constraints: 0x55 ) (AVCBox.53 InternalName: "check_meanElev" Disabled: 1 Listening: 1 Label: "Mean Elevation" Constraints: 0x55 ) (AVCBox.54 InternalName: "check_meanSlope" Disabled: 1 Listening: 1 Label: "Mean Slope" Constraints: 0x55 ) (AVCBBox.55 InternalName: "cboWatershed" Help: "ComboBox" Update: "Hydro.dd.cboWatershed.Update" NextControl: 36 ContentKind: 4 Constraints: 0x55 Listening: 1 Label: " " Select: "Hydro.dd.cboWatershed.Select" ) (RButn.56 InternalName: "optDEM" Constraints: 0x55 Listening: 1 Label: "Delineate from DEM" Click: "Hydro.dd.OptDem_Click" ) (RButn.57 InternalName: "optWatershed" Constraints: 0x55 Listening: 1 Label: "Use Existing Watershed" Click: "Hydro.dd.OptWatershed_Click" ) (TextLabel.58 InternalName: "lblWatershed" Constraints: 0x55 Label: "Existing Watershed" Listening: 1 ) (RectD.59 Left: 189.00000000000000 Top: 298.00000000000000 Right: 252.00000000000000 Bottom: 263.00000000000000 ) (RectD.60 Left: 182.00000000000000 Top: 136.00000000000000 Right: 413.00000000000000 Bottom: 48.00000000000000 ) (RectD.61 Left: 21.00000000000000 Top: 69.00000000000000 Right: 164.00000000000000 Bottom: 48.00000000000000 ) (RectD.62 Left: 14.00000000000000 Top: 140.00000000000000 Right: 173.00000000000000 Bottom: 119.00000000000000 ) (RectD.63 Left: 156.00000000000000 Top: 252.00000000000000 Right: 275.00000000000000 Bottom: 224.00000000000000 ) (RectD.64 Left: 291.00000000000000 Top: 298.00000000000000 Right: 354.00000000000000 Bottom: 263.00000000000000 ) (RectD.65 Left: 88.00000000000000 Top: 298.00000000000000 Right: 151.00000000000000 Bottom: 263.00000000000000 ) (RectD.66 Left: -208.00000000000000 Top: 155.00000000000000 Right: -145.00000000000000 Bottom: 120.00000000000000 ) (RectD.67 Left: 11.00000000000000 Top: 170.00000000000000 Right: 144.00000000000000 Bottom: 147.00000000000000 ) (RectD.68 Left: 11.00000000000000 Top: 195.00000000000000 Right: 118.00000000000000 Bottom: 172.00000000000000 ) (RectD.69 Left: 11.00000000000000 Top: 219.00000000000000 Right: 108.00000000000000 Bottom: 196.00000000000000 ) (RectD.70 Left: 129.00000000000000 Top: 168.00000000000000 Right: 224.00000000000000 Bottom: 145.00000000000000 ) (RectD.71 Left: 269.00000000000000 Top: 169.00000000000000 Right: 429.00000000000000 Bottom: 146.00000000000000 ) (RectD.72 Left: 269.00000000000000 Top: 194.00000000000000 Right: 413.00000000000000 Bottom: 171.00000000000000 ) (RectD.73 Left: 268.00000000000000 Top: 219.00000000000000 Right: 408.00000000000000 Bottom: 196.00000000000000 ) (RectD.74 Left: 130.00000000000000 Top: 194.00000000000000 Right: 264.00000000000000 Bottom: 171.00000000000000 ) (RectD.75 Left: 129.00000000000000 Top: 222.00000000000000 Right: 248.00000000000000 Bottom: 194.00000000000000 ) (RectD.76 Left: 181.00000000000000 Top: 160.00000000000000 Right: 413.00000000000000 Bottom: 82.00000000000000 ) (RectD.77 Left: 50.00000000000000 Top: 33.00000000000000 Right: 191.00000000000000 Bottom: 15.00000000000000 ) (RectD.78 Left: 236.00000000000000 Top: 31.00000000000000 Right: 414.00000000000000 Bottom: 14.00000000000000 ) (RectD.79 Left: 23.00000000000000 Top: 95.00000000000000 Right: 153.00000000000000 Bottom: 80.00000000000000 ) (Nil.80 ) (Script.81 Name: "hydro.AddBasinId" SourceCode: "'*****************************************\n' Name: hydro.AddBasinId\n' Headline: \n' Self: {aFtab,OrgIdFldName,NewIdFldName} \n' Returns: True if Added, False, if not.\n' Description: Add BasinId field to the Ftab.\n' Topics:\n' Search Keys:\n' Requires:\n' History: 10/4\n'*****************************************\nTheFtab=SELF.Get(0)\nOrgIdName=SELF.Get(1)\nNewIdName=SELF.Get(2)\nif(TheFtab.CanEdit)then\n TheFtab.SetEditable(True)\nelse\n return False\nend\nOrgIdFld=TheFtab.FindField(OrgIdName)\nif(OrgIdFld=nil)then\n ret urn False\nend\nNewIdFld=Field.Make(NewIdName,OrgIdFld.GetType,OrgIdfld.GetWidth,OrgIdFld.GetPrecision)\nTheFtab.AddFields({NewIdFld})\nfor each rec in TheFtab\n TheFtab.SetValue(NewIdFld,rec,TheFtab.ReturnValue(OrgIdfld,rec))\nend\nTheFtab.SetEditable(False)\nreturn True\n" ) (Script.82 Name: "Hydro.AttachAttribute" SourceCode: "'*****************************************\n' Name: Hydro.AttachAttribute\n' Headline: \n' Self: {Ftab,Vtab,FtabFld,VtabFld}\n' Returns: True if worked properly, False if not.\n' Description: Attach the attribute fields\n' to the ShapeFile. \n' Topics: \n' Search Keys:\n' Requires: \n' History: 11/03/97\n'*****************************************\nTheFtab=SELF.Get(0)\nTheVtab=SELF.Get(1)\nTheFtabIdFld=SELF.Get(2)\nTheVtabIdFld=SELF.Get(3)\nTheVtabIdFldName=TheVtabIdFld.GetName\n\nif(TheFtab.CanEdit)then\n TheFtab.SetEditab le(true)\nelse\n Return false\nend\n'Appending the Attribute fields to the Ftab.\nTheVtabFlds=TheVtab.GetFields\nFldsToBeAdded=List.Make\nfor each fld in TheVtabFlds\n tmpFldName=fld.GetName\n tmpFld=TheFtab.FindField(tmpFldName)\n if(tmpFld=nil)then\n FldsToBeAdded.Add(fld.Clone)\n end\nend\nif(FldsToBeAdded.Count>0)then\n TheFtab.AddFields(FldsToBeAdded)\nend\n\nIdToRecDict=Dictionary.Make(TheFtab.GetNumRecords)\nfor each rec in TheFtab\n TheId=TheFtab.ReturnValue(TheFtabIdFld,rec)\n IdToRecDict.Add(TheId,rec.Clone )\nend\n\nfor each rec in TheVtab\n TheId=TheVtab.ReturnValue(TheVtabIdFld,rec)\n TheRec=IdToRecDict.Get(TheId)\n if(TheRec=nil)then\n Continue\n end\n for each Vfld in TheVtab.GetFields\n TheFldName=Vfld.GetName\n if(TheFldName=TheVtabIdFldName)then\n Continue\n end\n TheFld=TheFtab.FindField(TheFldName)\n if(TheFld=nil)then\n Continue\n end\n TheValue=TheVtab.ReturnValue(Vfld,rec)\n TheFtab.SetValue(TheFld,TheRec,TheValue)\n end\nend \nreturn true \n \n " ) (Script.83 Name: "Hydro.BasinLength" SourceCode: "' Basin Length script\n'\n' Active theme: Watershed\n' User selects theme: Pour points\n\ntheView = av.GetActiveDoc\nt = theView.GetActiveThemes.Get(0)\ng = t.GetGrid\ntheBasinVTab = t.GetVTab\ngThemeList = theView.GetThemes\nCounter = 0\n'l = {}\n\nif (theBasinVTab.GetSelection.Count = 0) then\n msgbox.info(\"Please select some watersheds.\",\"Hydro\")\n Return NIL\nend\n\nif (theBasinVTab.GetSelection.Count > 49) then\n msgbox.info(\"Please select less than 50 watersheds\",\"Hydro\")\n Return NIL\nend\n\n'make sure the list contains only grid themes\ngridThemeList = {}\nfor each thm in theView.GetThemes\n if (thm.Is(GTHEME).Not) then\n Continue\n else\n gridThemeList.Add(thm)\n end \nend\n\npourTheme = MsgBox.Choice(gridThemeList,\n \"Please select a theme of pour points\", \"Watershed\")\n if (pourTheme = NIL) then return NIL end\n \ntheVTab = pourTheme.GetVtab\nbasinIDField = theBasinVTab.FindField(\"Value\")\n\n if(theBasinVTab.GetSelection.Count = 0) then\n M sgBox.Info(\"Please select some watersheds in\"++\n t.GetName,\"Hydro\")\n Return NIL\n end \n \n for each rec in theBasinVTab.GetSelection \n \n basinID = theBasinVTab.ReturnValue(basinIDField, rec)\n r1 = (g <> basinID).SetNull(0.AsGrid)\n r2 = (pourTheme.GetGrid <> basinID).Setnull(pourTheme.GetGrid)\n r3 = r2.EucDistance(NIL, NIL, NIL)\n r4 = (r1 + r3) '.GetStatistics.Get(1).AsGrid\n r5 = (r1 < (0)).SetNull(r4.GetStatistics.Get(1).AsGrid)\n \n if (counter = 0) then\n r = r5\n counter = 1\n else\n newR = r\n r = newR.Merge({r5})\n end \n end\n\n' rename data set\naFN = av.GetProject.GetWorkDir.MakeTmp(\"blen\", \"\")\nr.Rename(aFN)\n\n' check if output is ok\nif (r.HasError) then return NIL end\n\n' create a theme \ngthm = GTheme.Make(r) \n\n' set name of theme\ngthm.SetName(\"Length\")\n\n' add theme to the specifiedView\ntheView.AddTheme(gthm)\n" ) (Script.84 Name: "Hydro.BigHydro" SourceCode: "av.GetProject.FindDialog(\"Hydrologic Modeling\").Open" ) (Script.85 Name: "Hydro.CalculateArea" SourceCode: "' Area script\n'\n' Active theme: Watershed\n\ntheView = av.GetActiveDoc\nt = theView.GetActiveThemes.Get(0)\ng = t.GetGrid\n\n'find the area values for each basin (zone)\nr = g.ZonalGeometry(#GRID_GEOMDESC_AREA)\n\n' rename data set\naFN = av.GetProject.GetWorkDir.MakeTmp(\"area\", \"\")\nr.Rename(aFN)\n\n' check if output is ok\nif (r.HasError) then return NIL end\n\n' create a theme \ngthm = GTheme.Make(r) \n\n' set name of theme\ngthm.SetName(\"Area of\"++t.GetName)\n\n' add theme to the specifiedView\ntheView.AddTheme(gthm)\n\n" ) (Script.86 Name: "Hydro.CalculatePerimeter" SourceCode: "' Perimeter script\n'\n' Active theme: Watershed\n\ntheView = av.GetActiveDoc\nt = theView.GetActiveThemes.Get(0)\ng = t.GetGrid\n\n'find the perimeter values for each basin (zone)\nr = g.ZonalGeometry(#GRID_GEOMDESC_PERIMETER)\n\n' rename data set\naFN = av.GetProject.GetWorkDir.MakeTmp(\"perim\", \"\")\nr.Rename(aFN)\n\n' check if output is ok\nif (r.HasError) then return NIL end\n\n' create a theme \ngthm = GTheme.Make(r) \n\n' set name of theme\ngthm.SetName(\"Perimeter of\"++t.GetName)\n\n' add theme to the specifiedView\ntheView. AddTheme(gthm)\n" ) (Script.87 Name: "Hydro.Centroid" SourceCode: "' Centroid script\n'\n' Active theme: Watershed\n\ntheView = av.GetActiveDoc\nt = theView.GetActiveThemes.Get(0)\ng = t.GetGrid\n\n'find the centroid for each basin (zone)\nr = g.ZonalGeometry(#GRID_GEOMDESC_CENTROID)\n\n' check if output is ok\nif (r.HasError) then return NIL end\n\naFN = av.GetProject.GetWorkDir.MakeTmp(\"Cnt\",\"shp\")\npntFtab=r.AsPointFTab (aFN,Prj.MakeNULL)\nAddBasinID=av.run(\"hydro.AddBasinId\",{pntFtab,\"Grid_Code\",\"BasinId\"})\npntFthm=FTheme.Make(pntFtab)\n\n' set name of theme\npntFthm.SetName(\"Centroids of\"++t.getname)\n\n' add theme to the specifiedView\ntheView.AddTheme(pntFthm)\n" ) (Script.88 Name: "hydro.ChkName83" SourceCode: "'*****************************************\n' Name: hydro.ChkName83\n' Headline: \n' Self: {FileName}\n' Returns: True/False\n' Description: Returns nil if not 8.3, otherwise,\n' The filename. \n' Topics:\n' Search Keys:\n' Requires:\n' History:\n'*****************************************\nOutName=Self.Get(0)\nNameOk=False\nWhile(Not NameOK)\n NameOK=True \n if(OutName.Count>12)then\n NameOk=False\n else\n OutNameList=OutName.AsTokens(\".\")\n if(OutNameList.Get(0).Count>8)then\n NameOk=False\n elseif(OutNam eList.Count=2)then\n if(OutNameList.Get(1).Count>3)then\n NameOk=False\n end\n end\n end\n if(not NameOk)then\n OutName=msgbox.input(OutName ++ \"does not comply with 8.3 naming convension\" +nl+\"Give a shorter name below\",\n Script.The.GetName,OutName)\n if(OutName=nil)then\n exit\n else\n continue\n end\n else\n return OutName\n end\nend\n\n\n'' 12. d:\\tnrcc\\aveprog\\hydro.ChkName83 of 40 lines,\n" ) (Script.89 Name: "Hydro.CurveNumber" SourceCode: "' Curve Number script\n'\n' Active theme: Watershed\n' User selects theme: Curve number\n\ntheView = av.GetActiveDoc\nt = theView.GetActiveThemes.Get(0)\ng = t.GetGrid\n\n'Get the grid theme table\nzoneObj = t.GetVTab\n\n'get zone Field from zoneObj\nzoneField = zoneObj.FindField(\"Value\")\n\n'make sure the list contains only grid themes\ngridThemeList = {}\nfor each thm in theView.GetThemes\n if (thm.Is(GTHEME).Not) then\n Continue\n else\n gridThemeList.Add(thm)\n end \nend\n\n' get value theme\nvalueTheme = MsgBo x.Choice(gridThemeList,\n \"Please Select a Curve Number Theme\",\"Hydro\")\n if (valueTheme = NIL) then Return NIL end\n\n' obtain grid from value theme and create VTab\ntheGrid = valueTheme.GetGrid\naPrj = theView.GetProjection\nr = theGrid.ZonalStats(#GRID_STATYPE_MEAN,\n g,\n aPrj,\n zoneField,\n FALSE)\n\n' rename data set\naFN = av.Get Project.GetWorkDir.MakeTmp(\"curv\", \"\")\nr.Rename(aFN)\n\n' check if output is ok\nif (r.HasError) then return NIL end\n\n' create a theme \ngthm = GTheme.Make(r) \n\n' set name of theme\ngthm.SetName(\"Mean Curve Number\")\n\n' add theme to the specifiedView\ntheView.AddTheme(gthm)" ) (Script.90 Name: "Hydro.dd.Activate" SourceCode: "self.FindByname(\"cbx_Themes\").Update\n'self.FindByname(\"lbx_Records\").Update\n" ) (Script.91 Name: "Hydro.dd.BasinLength" SourceCode: "'*****************************************\n' Name: Hydro.dd.BasinLength\n' Headline: \n' Self: {TheView,{WatershedGrd, PourPointGrd}}\n' Returns: BasinLengthGrid (wLength)\n' Description: Cal. BasinLength(wLength).\n' BasinLength is the longest distance between\n' the PourPoint and basin boundary line. \n' Topics:\n' Search Keys:\n' Requires:\n' History: 8/18\n'*****************************************\nTheView=SELF.Get(0)\nif(SELF.Get(1).Is(LIST))then\n WaterGrd=SELF.Get(1).Get(0)\n PpntGrd=SELF.Get(1).Get(1)\nelse\n Return nil\nend\n\nCounter=0\nTheBasinVtab=WaterGrd.GetVtab\n\n'TheBasinVtab.GetSelection.SetAll\n\n'if (theBasinVTab.GetNumRecords > 49) then\n' msgbox.info(\"Please select less than 50 watersheds\",\"Hydro\")\n' Return NIL\n'end\n\ntheVTab = PpntGrd.GetVtab\n\nbasinIDField = theBasinVTab.FindField(\"Value\")\n\nfor each rec in theBasinVTab '.GetSelection \n basinID = theBasinVTab.ReturnValue(basinIDField, rec)\n r1 = (WaterGrd <> basinID).SetNull(0.AsGrid)\n r2 = (PpntGrd <> basinID).SetNull(PpntGrd)\n r3 = r 2.EucDistance(NIL, NIL, NIL)\n r4 = (r1 + r3)\n r5 = (r1 < (0)).SetNull(r4.GetStatistics.Get(1).AsGrid)\n \n if (counter = 0) then\n r = r5\n counter = 1\n else\n newR = r\n r = newR.Merge({r5})\n end \nend 'TheBasinVtab.GetSelection\n\n'theBasinVtab.GetSelection.ClearAll\n\n' check if output is ok\nif (r.HasError) then \n return NIL\nelse\n return r\nend" ) (Script.92 Name: "Hydro.dd.btn.Click" SourceCode: "self.getdialog.close" ) (Script.93 Name: "Hydro.dd.btn_FillSinks.Update" SourceCode: "self.SetEnabled((self.GetDialog.FindByName(\"cbx_Themes\").GetObjectTag <> NIL))\n\n\n" ) (Script.94 Name: "Hydro.dd.btn_OK.click" SourceCode: "'*****************************************\n' Name: Hydro.dd.btn_OK.click\n' Headline: \n' Self: btn_OK,(CommandButton) \n' Returns: \n' Description: Adding attributs to a watershed's\n' Ftab (for Shp) or Vtab (For Grd). \n' The Program does the followings:\n' (1) Chk if optDEM is selected. (the other opt is optWatershed)\n' (2) if optDEM is selected, and WatershedThm has a Dict objectTag.\n' it proceed to get the Grds necessary for operation.\n' (3) if optDEM is selected and WatershedThm did not return the correct GRDs\n' or optWatershed is selected, then\n' it proceed to get the ElevGrd from cbx_Themes.GetCurrentValue.GetGrid.\n' fill the ElevGrd and get the FlowDirGrd and WatershedGrd.\n' Disable the operations that needs ppntGrd,rivGrd.\n' (4) Process the available grids (ElevGrd,FdirGrd,WaterGrd,(PpntGrd,RivGrd when available))\n' to get the parameters.\n' Topics:\n' Search Keys:\n' Requires:\n' History: 8/15\n'*****************************************\nTheView = av.GetActiveDoc\nTheWkDi r=av.GetProject.GetWorkDir\nif (TheView.GetClass.GetClassname <> \"View\") Then\n MsgBox.Info(\"Please make a view active\",\"\")\n Exit 'yz. 8/15\nend\n\nelevKey=\"elev\"\nfdirKey=\"fdir\"\nrivKey=\"riv\"\nppntKey=\"ppnt\"\nwaterKey=\"water\"\n\nTheDialog=SELF.GetDialog\nTheControls = TheDialog.GetControlPanel\n\ndz=34.AsChar\n\noptDEM=TheDialog.FindByName(\"optDEM\")\n\nbtnOK=TheDialog.FindByName(\"btn_OK\")\nif(optDEM.isSelected)Then 'WhenDEM is selected, AllGrids are available.\n TheGrdDict=av.run(\"Hydro.dd.Watershed\",{TheView,T heDialog,TheWkDir})\n if(TheGrdDict.Is(Dictionary).not)Then\n return nil\n else\n elevGrd=TheGrdDict.Get(elevKey) 'Elevation Grid.\n fdirGrd=TheGrdDict.Get(fdirKey) 'FlowDirction Grid.\n rivGrd=TheGrdDict.Get(rivKey) 'River Grid.\n ppntGrd=TheGrdDict.Get(ppntKey) 'PourPoint Grid.\n WaterGrd=TheGrdDict.Get(waterKey)\n end \nelse 'Watershed is provided. \n cboWatershed=TheDialog.FindByName(\"cboWatershed\")\n cboDEM=TheDialog.FindByName(\"cbx_Themes\")\n WatershedThm=cboWatershed.GetCurr entValue\n ElevThm=cboDEM.GetCurrentValue\n if(ElevThm.GetName=WatershedThm.GetName)then\n msgbox.Warning(\"Same Grid is Selected as Watershed and Elevation Grid.\"+nl+\"EXIT...\",Script.The.GetName)\n Exit \n end\n if((WatershedThm.Is(FTheme)) or (WatershedThm.Is(GTheme)))then\n ThmGrds=av.run(\"Hydro.dd.GetWaterElevGrds\",{TheView,TheDialog,WatershedThm})\n if(ThmGrds.Is(List))then\n elevGrd=ThmGrds.Get(0)\n elevGrd=av.run(\"Hydro.dd.FillSinks\",elevGrd)\n if(elevGrd.is(Grid).not)then\n exit\n end\n fdirGrd=elevGrd.FlowDirection(False) \n WaterGrd=ThmGrds.Get(1)\n else\n exit\n end\n else\n exit\n end\nend\n'Construct the NameList of items to be operated.\n \nnameList = {}\n\nfor each c in TheControls\n if ((c.GetClass.GetClassName = \"CheckBox\")and(c.IsSelected)) Then\n nameList.Add(c)\n end\nend\n\nstringList = \"\"\nfor each name in nameList\n stringList = stringList+nl+name.getname\nend\n\naFileName = FileDialog.Put(\"watrshed.shp\".asfilename,\"*.shp\",\"Output Watershed A s Shapefile\")\n'aFileName = \"$home/watrshed.shp\".AsFileName\nif(aFileName=nil)Then 'Cancel Button Pressed.\n exit\nend\n\naPrj = TheView.GetProjection\n\nTheResult = WaterGrd.AsPolygonFTab(aFileName,false,aPrj)\nTheFTheme = FTheme.Make(TheResult)\nTheFTab = TheFTheme.GetFTab\nshapeField = TheFTab.FindField(\"Shape\")\nidField = TheFTab.FindField(\"gridcode\")\n\nstringOfFields = dz+\"ID\"+dz+\",\"+dz+\"basinid\"+dz\n\n'*************************Add Centroid ************************\nif (stringList.contains(\"check_Centroid\")) Then\n stringOfFields = stringOfFields+\",\"+dz+\"centroidx\"+dz+\",\"+dz+\"centroidy\"+dz\nend\n\n'***************************Add Area ************************\nif (stringList.contains(\"check_area\") or stringList.contains(\"check_sFactor\")) Then\n\n TheAreaGrid = WaterGrd.ZonalGeometry(#GRID_GEOMDESC_AREA)\n if(stringList.contains(\"check_area\"))Then\n stringOfFields = stringOfFields+\",\"+dz+\"basinarea\"+dz\n end\nend\n\n\n'\n''***************************Add Perimeter*******************\n'\nif (stringList.contains(\"check_Perimeter\")) Then\n \n ThePerimeterGrid = WaterGrd.ZonalGeometry(#GRID_GEOMDESC_PERIMETER)\n stringOfFields = stringOfFields+\",\"+dz+\"perimeter\"+dz\n\nend\n\n'**** Adding WL, FL, FD, SF, ME, MS yz 8/15 ********\nif (stringList.contains(\"check_wlength\") or stringList.contains(\"check_sFactor\"))Then\n 'InThms=av.run(\"Hydro.GetInThms\",{TheView,{wshdTag,ppntTag}}) '-> {WshdGrd,PPntGrd}\n wLengthGrd=av.run(\"Hydro.dd.BasinLength\",{TheView,{waterGrd,ppntGrd}})\n if(wLengthGrd.Is(Grid) and stringList.contains(\"check_wlength\"))Then \n stringOfFields=stringOfFields+\",\"+dz+\"basinlen\"+dz\n end\nend 'wLength\n\nif (stringList.contains(\"check_fDist\")) Then\n 'InThms=av.run(\"Hydro.GetInThms\",{TheView,{wshdTag,FdirTag}}) '-> {WshdThm,FdirThm}\n mfDistGrd=av.run(\"Hydro.dd.fDist\",{TheView,{waterGrd,fdirGrd}}) '-> mfDistGrd\n if(mfDistGrd.Is(Grid))Then\n stringOfFields=stringOfFields+\",\"+dz+\"mfdist\"+dz\n end \nend 'fDist\n\nif (stringList.contains(\"check_fLength\")) Then\n 'InThms=av.run(\"Hydro.GetInThms\",{TheView,{RivTag,wshdTag,F dirTag}}) '-> {RiverGrd,FdirGrd}\n mfstDistGrd=av.run(\"Hydro.dd.fstDist\",{TheView,{rivGrd,waterGrd,fdirGrd}}) '-> mfstDistGrd\n if(mfstDistGrd.is(GRID))Then\n stringOfFields=stringOfFields+\",\"+dz+\"mstdist\"+dz\n end \nend 'fLength\n\nif (stringList.contains(\"check_sFactor\")) Then\n stringOfFields=stringOfFields+\",\"+dz+\"shapefact\"+dz\nend 'sFactor\n\nif (stringList.contains(\"check_meanElev\")) Then\n 'InThms=av.run(\"Hydro.GetInThms\",{TheView,{wshdTag,ElevTag}})\n meanElevGrd=av.run(\"Hydro.dd.meanEle v\",{TheView,{waterGrd,elevGrd}})\n if(meanElevGrd.is(GRID))Then\n stringOfFields=stringOfFields+\",\"+dz+\"meanelev\"+dz\n end\nend 'meanElv\n\n\nif (stringList.contains(\"check_meanslope\")) Then\n 'InThms=av.run(\"Hydro.GetInThms\",{TheView,{wshdTag,ElevTag}})\n basinslopeGrd=av.run(\"Hydro.dd.MeanSlope\",{TheView,{waterGrd,elevGrd}})\n if(basinslopeGrd.is(GRID))Then\n stringOfFields=stringOfFields+\",\"+dz+\"basinslop\"+dz\n end \nend 'meanSlope\n\n''***************************\n\nTheFN = \"$home/pnt.txt\".AsFilen ame\nTheWriteFile = lineFile.Make(TheFN,#File_PERM_WRITE)\nTheWriteFIle.WriteElt(stringOfFields)\nwriteString = \"\"\n\nfor each r in TheFTab\n \n ID = TheFTab.ReturnValue(idField,r).Asstring\n writeString = ID+\",\"+ID\n pCenter=TheFTab.ReturnValue(shapeField,r).ReturnCenter '8/18\n if (stringOfFields.Contains(\"centroidx\")) Then\n X = pCenter.GetX.Setformat(\"d.d\").AsString\n Y = pCenter.GetY.Setformat(\"d.d\").AsString \n writeString = writeString+\",\"+X+\",\"+Y\n end\n \n if (stringOfFields.Contains(\"bas inArea\") or stringOfFields.Contains(\"shapefact\")) Then\n Area = TheFtab.ReturnValue(shapeField,r).ReturnArea\n if (area.AsString = \"number null\") Then\n area = 0\n end\n if(stringOfFields.Contains(\"basinarea\"))Then\n area.setformat(\"d\")\n writeString = writeString+\",\"+area.AsString\n end\n end\n \n if (stringOfFields.Contains(\"Perimeter\")) Then\n Perm=TheFtab.ReturnValue(shapeField,r).ReturnLength\n if (perm.AsString = \"number null\") Then\n perm = 0\n end\n perm.setformat (\"d\")\n writeString = writeString+\",\"+perm.AsString\n end\n\n if(stringOfFields.Contains(\"basinlen\") or stringOfFields.Contains(\"shapefactor\"))Then\n BasinLengV=wLengthGrd.CellValue(pCenter, aPrj)\n if(BasinLengV.AsString=\"number null\")Then\n BasinLengV=0\n end\n BasinLengV.SetFormat(\"d\")\n if(stringOfFields.Contains(\"basinlen\"))Then\n writeString=writeString+\",\"+BasinLengV.AsString\n end\n end\n \n if(stringOfFields.Contains(\"mfdist\"))Then\n mfDistV=mfDistGrd.CellValue(pCenter,aPrj)\n mfDistV.Setformat(\"d\")\n if(mfDistV.AsString=\"number null\")Then\n mfDistV=0\n end\n writeString=writeString+\",\"+mfdistV.AsString \n end\n \n if(stringOfFields.Contains(\"mstdist\"))Then\n mstDistV=mfstDistGrd.CellValue(pCenter,aPrj)\n mstDistV.SetFormat(\"d\")\n if(mstDistV.AsString=\"number null\")Then\n mstDistV=0\n end\n writeString=writeString+\",\"+mstDistV.AsString\n end\n \n if(stringOfFields.Contains(\"shapefact\"))Then\n if(area>0)Then\n sfactorV=(BasinLengV^2)/area\n els e\n sfactorV=0\n end\n sfactorV.SetFormat(\"d.dd\")\n writeString=writeString+\",\"+sfactorV.AsString\n end\n \n if(stringOfFields.Contains(\"meanelev\"))Then\n meanElevV=meanelevGrd.CellValue(pCenter,aPrj)\n meanElevV.SetFormat(\"d.dd\")\n if(meanElevV.AsString=\"number null\")Then\n meanElevV=0\n end\n writeString=writeString+\",\"+meanElevV.AsString\n end\n \n if(stringOfFields.Contains(\"basinslop\"))Then\n basinSlopeV=basinslopeGrd.CellValue(pCenter,aPrj)\n basinSlopeV.SetFormat(\"d.ddd\")\n if(basinSlopeV.AsString=\"number null\")Then\n basinSlopeV=0\n end\n writeString=writeString+\",\"+basinSlopeV.AsString\n end\n \n TheWriteFile.WriteElt(writeString)\n writeString = \"\"\n \nend \n\nTheWriteFile.Close\nBigTable = VTab.Make(TheFN,False,False)\nBigField = BigTable.FindField(\"ID\")\n\n'Update Grid Vtab.\nWaterVtab=WaterGrd.GetVtab\n if(WaterVtab=nil)then\n WaterVtab=WaterGrd.BuildVtab\n end\n if(WaterVtab.is(Vtab))then \n TheFld=WaterVtab.FindField(\"Value\")\n av.run(\"Hydro.AttachAttribute \",{WaterVtab,BigTable,TheFld,BigField})\n 'waterVtab.Join(TheFld,BigTable,BigField)\n WaterTbl=Table.Make(waterVtab)\n WaterTbl.GetWin.Open\n WaterTbl.SetName(\"Attributes of\"++WaterVtab.GetName)\n end \n'Update Ftab if Output Shp is selected.\nif (stringList.contains(\"check_OutShape\")) Then\n av.run(\"Hydro.AttachAttribute\",{TheFtab,BigTable,idField,Bigfield})\n 'TheFTab.Join(idField,BigTable,BigField)\n TheView.AddTheme(TheFTheme)\n TheFTheme.SetVisible(True)\n TheTable = Table.Make(TheFTab)\n TheTab le.GetWin.Open\n TheTable.SetName(\"Attributes of\"++TheFTheme.Getname)\nend\n\n\n\n\n\n\n\n" ) (Script.95 Name: "Hydro.dd.btn_OK.Update" SourceCode: "'Since chkOutputGrd is remove, This program is no longer needed.\ntheControls = SELF.GetDialog.GetControlPanel\nstat = 0\nfor each c in theControls\n if ((c.GetName=\"Check_OutGrid\") or (c.GetName=\"Check_OutShape\"))then\n continue\n end\n \n if(c.GetName.Contains(\"Check\") and (c.IsSelected)) then\n stat = stat + 1\n end\nend\n\nctlOutShp=theControls.FindByName(\"check_OutShape\")\nctlOutGrd=theControls.FindByName(\"check_OutGrid\")\nOptDem=TheControls.FindByName(\"OptDEM\")\nOptWatershed=TheControls.FindByName(\"OptWa tershed\")\n\nif(stat>0)then\n ctlOutShp.SetEnabled(True)\n ctlOutGrd.SetEnabled(True)\nelse\n ctlOutShp.SetEnabled(False)\n ctlOutGrd.SetEnabled(False)\nend\n\n\nif ((OptDEM.IsSelected or stat>0)) then \n self.Setenabled(true)\nelse\n SELF.SetEnabled(False)\n return nil\nend" ) (Script.96 Name: "Hydro.dd.cboWatershed.Select" SourceCode: "'*****************************************\n' Name: Hydro.dd.cboWatershed.Select\n' Headline: \n' Self: comboBox\n' Returns: \n' Description: Updates check boxes and \n' OK buttons based on the selection.\n' Topics:\n' Search Keys:\n' Requires:\n' History: 9/3\n'*****************************************\nt = self.GetCurrentValue\nTheDialog=SELF.GetDialog\nTheView=av.GetActiveDoc\nTheWaterThm=SELF.GetCurrentValue\noptWatershed=TheDialog.FindByName(\"optWatershed\")\noptWatershed.Click\n\n" ) (Script.97 Name: "Hydro.dd.cboWatershed.Update" SourceCode: "'*****************************************\n' Name: Hydro.dd.cboWatershed.Update\n' Headline: \n' Self:\n' Returns: \n' Description: Update cboWatershed with\n' a list of predelineated watersheds. \n' Topics:\n' Search Keys:\n' Requires:\n' History:\n'*****************************************\nv = self.GetDialog.GetactiveDoc\nif (v.Is(View) and v.GetThemes.IsEmpty.Not) Then \n Self.SetEnabled(true)\n theThemes = v.GetThemes \n wshThmList=List.Make\n for each thm in v.GetThemes\n if((thm.Is(FTheme)) or (thm.Is (GTheme)))then\n 'if(thm.GetObjectTag.Is(Dictionary))then\n WshThmList.Add(thm)\n 'end\n end \n end\n Self.DefineFromList(WshThmList)\nelse\n Self.SetEnabled(false)\nend\n" ) (Script.98 Name: "Hydro.dd.cbx_Themes.Update" SourceCode: "v = self.GetDialog.GetactiveDoc\n\nif (v.Is(View) and v.GetThemes.IsEmpty.Not) Then\n \n Self.SetEnabled(true)\n theThemes = v.GetThemes\n \n gridThemeList = {}\n wshThmList=List.Make\n for each thm in v.GetThemes\n if (thm.Is(GTHEME).Not) then\n continue\n else\n gridThemeList.Add(thm)\n end \n end\n \n 'gridThemeList.Insert(\"\")\n self.DefineFromList(gridThemeList)\n 'self.GetDialog.SetServer(theThemes.Get(0).GetvTab)\nelse\n self.SetEnabled(false)\nend\n" ) (Script.99 Name: "Hydro.dd.Check.click" SourceCode: "self.Getdialog.findbyname(\"btn_OK\").update" ) (Script.100 Name: "Hydro.dd.check_OutShape" SourceCode: "'MsgBox.Info(\"You are about to make a Shapefile\",\"\")\nself.Getdialog.findbyname(\"btn_OK\").update" ) (Script.101 Name: "Hydro.dd.ChkBoxes.Checked" SourceCode: "'*****************************************\n' Name: Hydro.dd.ChkBoxes.Checked\n' Headline: \n' Self: {TheDialog,True/False}\n' Returns: nil \n' Description: (Called by Hydro.dd.Open)\n' to enable and chk all the checkBoxes on Start.\n' Requires:\n' History: 9/27\n'*****************************************\nTheDialog=SELF.Get(0)\nblnChecked=SELF.Get(1)\n\n'Set Predefined watershed controls.\nTheCtrls=TheDialog.GetControlPanel\nfor each cn in TheCtrls\n if(cn.Is(CheckBox))then\n cn.SetEnabled(blnChecked)\n if((cn.GetNa me=\"check_sFactor\") or (cn.GetName=\"check_wLength\") or (cn.GetName=\"check_fLength\"))then\n cn.SetSelected(blnChecked.Not)\n else\n cn.SetSelected(blnChecked)\n end \n end\nend" ) (Script.102 Name: "Hydro.dd.ChkBoxes.Enabled" SourceCode: "'*****************************************\n' Name: Hydro.dd.ChkBoxes.Enabeld\n' Headline: \n' Self: {Dialog,True/False}\n' Returns: \n' Description: Enable/Disable the chkboxes.\n' Called by OptWatershed_click and OptDem_Click.\n' When OptWatershed is selected, wLength,sFactor,\n' and fLength can't be computed.\n' Topics:\n' Search Keys:\n' Requires:\n' History: 9/3\n'*****************************************\nTheDialog=SELF.Get(0)\nIsEnabled=SELF.Get(1)\n\n'msgbox.info(TheDialog.GetControlPanel.GetLabel,Script.The.GetN ame)\n'Get handles to all the chk boxes.\n'lblAttrb=TheDialog.FindByName(\"lblAttribute\")\n'lblAttrb.SetEnabled(IsEnabled)\nchkwLength=TheDialog.FindByName(\"check_wLength\")\nchkwLength.SetEnabled(isEnabled)\n'chkwLength.SetSelected(isEnabled)\nchksFactor=TheDialog.FindByName(\"check_sFactor\")\nchksFactor.SetEnabled(isEnabled)\n'chksFactor.SetSelected(isEnabled)\nchkfLength=TheDialog.FindByName(\"check_fLength\")\nchkfLength.SetEnabled(isEnabled)\n'chkfLength.SetSelected(isEnabled)" ) (Script.103 Name: "Hydro.dd.DisableRivPpntChkBox" SourceCode: "'*****************************************\n' Name: Hydro.dd.DisableRivPpntChkBox\n' Headline: \n' Self: {TheDialog}\n' Returns: nil\n' Description: Disable the check_boxes\n' that requires Riv, and Ppnt Grids. \n' Topics: \n' Search Keys:\n' Requires:\n' History: 9/4\n'*****************************************\nTheDialog=SELF.Get(0)\n\nchkBasinLength=TheDialog.FindByName(\"check_wLength\")\nchkFLength=TheDialog.FindByName(\"check_fLength\")\nchksFactor=TheDialog.FindByName(\"check_sFactor\")\nchkBasinLength.SetEnabled(False)\nc hkBasinLength.SetSelected(False)\nchkFLength.SetEnabled(False)\nchkFLength.SetSelected(False)\nchksFactor.SetEnabled(False)\nchksFactor.SetSelected(False)\n\n" ) (Script.104 Name: "Hydro.dd.fDist" SourceCode: "'*****************************************\n' Name: Hydro.dd.fDist\n' Headline: \n' Self: {TheView,{WaterGrd,FlowDirectionGrd}}\n' Returns: mfdist (OverlandFlowDist for each Sub-Watershed.\n' Description: Compute Max. overland flow dist. for a subWatershed. \n' Topics:\n' Search Keys:\n' Requires:\n' History: 8/18\n'*****************************************\nTheView=SELF.Get(0)\n\nif((SELF.Get(1)).Is(LIST))then \n WaterGrd=SELF.Get(1).Get(0)\n FlowDirGrd=SELF.Get(1).Get(1)\nelse\n Return nil\nend\n\n'chk=msgbox.yesno(\"Wate r=\"+WaterThm.getName,\"FDR=\"+FlowdirThm.GetName,False)\n' if(Chk)then\n' exit\n' end\n\nThePrj=TheView.GetProjection\nZoneObj=WaterGrd.GetVtab\nZoneFld=ZoneObj.FindField(\"Value\")\nfDistGrd=FlowDirGrd.FlowLength(Nil,True) 'True, for each cell, get its dist to upstream waterdevide.\nTheDistGrd=fDistGrd.ZonalStats(#GRID_STATYPE_MAX,WaterGrd,\n ThePrj,ZoneFld,\n False)\nif(TheDistGrd.HasError)then\n return nil\nelse\n return TheDistGrd\nend \n" ) (Script.105 Name: "Hydro.dd.Fill" SourceCode: "' Fill sink script\n'\n' Active theme: Elevation surface\n'msgbox.info(\"\",\"\")\n'exit\n\n\ntheView = av.GetActiveDoc\ntheTheme = av.FindDialog(\"Hydro\").FindByName(\"cbx_Themes\").GetObjectTag\n\n' fill active GTheme\n'theTheme = theView.GetActiveThemes.Get(0)\n\n' fill sinks in Grid until they are gone\nelevGrid = theTheme.GetGrid\nsinkCount = 0\nnumSinks = 0\nwhile (TRUE)\n flowDirGrid = elevGrid.FlowDirection(FALSE)\n sinkGrid = flowDirGrid.Sink\n if (sinkGrid.GetVTab = NIL) then\n ' check for errors\n if (sinkGrid.HasE rror) then return NIL end\n sinkGrid.BuildVAT\n end\n ' check for errors\n if (sinkGrid.HasError) then return NIL end\n if (sinkGrid.GetVTab <> NIL) then\n theVTab = sinkGrid.GetVTab\n numClass = theVTab.GetNumRecords\n newSinkCount = theVTab.ReturnValue(theVTab.FindField(\"Count\"),0)\n else\n numClass = 0\n newSinkCount = 0\n end\n if (numClass < 1) then\n break\n elseif ((numSinks = numClass) and (sinkCount = newSinkCount)) then\n break\n end\n waterGrid = flowDirGrid.Watershed(sinkGrid)\n zonalFillGrid = waterGrid.ZonalFill(elevGrid)\n fillGrid = (elevGrid < (zonalFillGrid.IsNull.Con(0.AsGrid,zonalFillGrid))).Con(zonalFillGrid,elevGrid)\n elevGrid = fillGrid\n numSinks = numClass\n sinkCount = newSinkCount\nend\n\n' rename data set\naFN = av.GetProject.GetWorkDir.MakeTmp(\"fill\", \"\")\nelevGrid.Rename(aFN)\n\n' create a theme \ntheGTheme = GTheme.Make(elevGrid) \n\n' set name of theme\ntheGTheme.SetName(\"Filled\"++theTheme.GetName)\n\n' add theme to the view\ntheView.AddTheme(theGTheme)" ) (Script.106 Name: "Hydro.dd.FillSinks" SourceCode: "'*****************************************\n' Name: Hydro.dd.FillSinks\n' Headline: \n' Self: ElevGrd\n' Returns: FilledGrd\n' Description: Takes in a ElevGrd\n' Returns a Filled ElevGrd.\n' Topics:\n' Search Keys:\n' Requires: Elevation Grd.\n' History: 9/3\n'*****************************************\nElevGrd=SELF\n\nTheFlowDirGrd=ElevGrd.FlowDirection(False)\n\n'Check for Sinks on The currently selected elevation grid's direction grid\nTheSinkGrid = TheFlowDirGrd.Sink\n \nif((TheSinkGrid.getVTab = NIL).Not) Then \n ' fill sinks in Grid until They are gone\n sinkCount = 0\n numSinks = 0\n while(TRUE) \n if(TheSinkGrid.GetVTab = NIL)Then\n ' check for errors\n if(TheSinkGrid.HasError)Then\n return NIL \n end\n TheSinkGrid.BuildVAT\n end\n ' check for errors\n if(TheSinkGrid.HasError)Then\n return NIL \n end\n if (TheSinkGrid.GetVTab <> NIL) Then\n TheVTab = TheSinkGrid.GetVTab\n numClass = TheVTab.GetNumRecords\n newSinkCount = TheVTab.ReturnValue(TheVT ab.FindField(\"Count\"),0)\n else\n numClass = 0\n newSinkCount = 0\n end\n if (numClass < 1) Then\n break\n elseif((numSinks = numClass) and (sinkCount = newSinkCount))Then\n break\n end\n waterGrid = TheFlowDirGrd.Watershed(TheSinkGrid)\n zonalFillGrid = waterGrid.ZonalFill(ElevGrd)\n fillGrid = (ElevGrd < (zonalFillGrid.IsNull.Con(0.AsGrid,zonalFillGrid))).Con(zonalFillGrid,ElevGrd)\n ElevGrd = fillGrid\n numSinks = numClass\n sinkCount = newSinkCount\n end 'While\nend 'Check for no sinks\n\nReturn ElevGrd" ) (Script.107 Name: "Hydro.dd.fstDist" SourceCode: "'*****************************************\n' Name: Hydro.dd.fstDist\n' Headline: \n' Self: {TheView,{RiverGrd,FlowDirectionGrd}}\n' Returns: mfdist (StreamFlowDist for each Sub-Watershed.\n' Description: Compute Max. stream flow dist. for a subWatershed. \n' Topics:\n' Search Keys:\n' Requires:\n' History: 8/18\n'*****************************************\nTheView=SELF.Get(0)\nif((SELF.Get(1)).Is(LIST))then\n RiverGrd=SELF.Get(1).Get(0)\n WaterGrd=SELF.Get(1).Get(1)\n FlowDirGrd=SELF.Get(1).Get(2)\nelse\n Return nil\nen d\n\n'chk=msgbox.yesno(\"River=\" + RiverThm.getName,\"Fdir\" + FlowdirThm.GetName,False)\n' if(Chk)then\n' exit\n' end\n\n\nRivVtab=RiverGrd.GetVtab\nRivFld=RivVtab.FindField(\"Value\")\n\nWaterVtab=WaterGrd.GetVtab\nWaterFld=WaterVtab.FindField(\"Value\")\n\nThePrj=TheView.GetProjection\nfDistGrd=FlowDirGrd.FlowLength(nil,False) 'True, for each cell, get its dist to upstream waterdevide.\n\n'Max and Min Flow Length on the river. FlowLen(Riv)=Max-Min.\nfMaxGrd=fDistGrd.ZonalStats(#GRID_STATYPE_MAX,RiverGrd,\n ThePrj,RivFld,\n False)\n\nfMinGrd=fDistGrd.ZonalStats(#GRID_STATYPE_MIN,RiverGrd,\n ThePrj,RivFld,\n False)\n\nRivfLengGrd=fMaxGrd-fMinGrd\nTheFLengGrd=RivfLengGrd.ZonalStats(#GRID_STATYPE_MAX,WaterGrd,\n ThePrj,WaterFld,\n False)\n\n \nif(ThefLengGrd.HasError)then\n return nil\nelse\n return TheFlengGrd\nend \n" ) (Script.108 Name: "Hydro.dd.GetWaterElevGrds" SourceCode: "'*****************************************\n' Name: Hydro.dd.GetWaterElevGrds\n' Headline: \n' Self: {TheView,TheDialog}\n' Returns: {WaterGrd,ElevGrd,WatershedThm}\n' Description: Called by Hydro.dd.btn_OK.click\n' The program disables operations (buttons) \n' that requires RiverGrd, or PpntGrd.\n' Returns WaterGrd, and ElevGrd. \n' Topics:\n' Search Keys:\n' Requires:\n' History: 9/3\n'*****************************************\nTheView=SELF.Get(0)\nTheDialog=SELF.Get(1)\nTheWaterThm=SELF.Get(2)\n\ncboThemes=TheDialog.Fi ndByName(\"cbx_Themes\")\nelevThm=cboThemes.GetCurrentValue\n\nif(elevThm.Is(Gtheme))then\n elevGrd=elevThm.GetGrid\nelse\n return nil 'Need some processing here.\nend\n\nIf(TheWaterThm.Is(GTheme))then\n WaterGrd=TheWaterThm.GetGrid\nelseif(TheWaterThm.Is(FTheme))then\n TheWaterFtab=TheWaterThm.GetFtab\n TheFld=Msgbox.ChoiceAsString(ThewaterFtab.GetFields,\"Select a key field for Ftab->Grid Conversion.\",\n Script.The.GetName)\n if(TheFld=nil)then\n exit\n end \n GrdSize=elevGrd.GetCellSize\n TheRect=elevGrd .GetExtent\n WaterGrd=Grid.MakeFromFTab(TheWaterFtab,TheView.GetProjection,TheFld,{GrdSize,TheRect}) \nelse\n return nil\nend\n\nav.run(\"Hydro.dd.DisableRivPpntChkBox\",{TheDialog})\n\nreturn {ElevGrd,WaterGrd}\n" ) (Script.109 Name: "Hydro.dd.Help" SourceCode: "\nMsgBox.Report(\"\"+nl+\n \"Select an elevation theme\"+NL+\n \"then click Delineate Watersheds.\"+NL+\n \"A preliminary watershed grid will\"+NL+\n \"be added to the current view.\"+NL+\n \"\"+NL+\n \"Choose any hydrologic attributes by\"+NL+\n \"clicking the check boxes.\"+NL+\n \"\"+NL+\n \"Choose output format(s)\"+NL+\n \"Click OK and the theme(s) will\"+NL+\n \"be added to the current view.\",\n \"Hydro Help\")" ) (Script.110 Name: "Hydro.dd.IdentifySinks" SourceCode: "' Identify Sink script\n'\n' Active theme: Flow Direction\n'\n\ntheView = av.GetActiveDoc\nt = av.FindDialog(\"Hydro\").FindByName(\"cbx_Themes\").GetObjectTag\n\n\nmsgbox.info(t.getclass.GetClassName,\"\")\n'exit\n't = theView.GetActiveThemes.Get(0)\ng = t.GetGrid\nr = g.Sink\n\n'Find out how many sinks were identified\nif (r.getVTab = NIL) then \n num = 0 'MsgBox.Info(\"No Sinks were identified!\",\"Identify Sinks\") \n Return num\nelse\n num = r.GetVTab.GetSelection.GetSize\n Return num\nEnd\n\n" ) (Script.111 Name: "Hydro.dd.meanElev" SourceCode: "'*****************************************\n' Name: Hydro.dd.meanElev\n' Headline: \n' Self: {theView,{WshdGrd,ElevGrd}}\n' Returns: MeanElevGrd.\n' Description: MeanElevation For subWatershed.\n' Topics:\n' Search Keys:\n' Requires:\n' History: 8/21\n'*****************************************\ntheView = SELF.Get(0)\nif((SELF.Get(1)).Is(LIST))then\n WatershedGrd=SELF.Get(1).Get(0)\n ElevGrd=SELF.Get(1).Get(1)\nelse\n return nil\nend\n\n'Get the grid theme table\nWaterVtab = WatershedGrd.GetVTab\n\n'get zone Field from zoneObj \nzoneField = WaterVtab.FindField(\"Value\")\n\naPrj = theView.GetProjection\n\nr = ElevGrd.ZonalStats(#GRID_STATYPE_MEAN,WaterShedGrd,aPrj,zoneField,FALSE)\nreturn r\n" ) (Script.112 Name: "Hydro.dd.MeanSlope" SourceCode: "'*****************************************\n' Name: Hydro.dd.MeanSlope\n' Headline: \n' Self: {View,{WatershedGrd,ElevGrd})\n' Returns: MeanSlopeGrd for subBasins.\n' Description: The program takes WatershedGrd\n' and ElevGrd as inputs and produce MeanSlopeGrd\n' as an output. (SlopeGrd was calculated as\n' an intermediate processing result)\n' Topics: Hydro.dialog.\n' Search Keys:\n' Requires:\n' History: 8/28\n'*****************************************\ntheView=SELF.Get(0)\nif(SELF.Get(1).Is(LIST))then \n WaterGrd= SELF.Get(1).Get(0)\n ElevGrd=SELF.Get(1).Get(1)\nelse\n Return nil\nend\n\n'WaterGrd=WaterThm.GetGrid\n'ElevGrd=ElevThm.GetGrid\n\nWaterVtab=WaterGrd.GetVtab\nWaterFld=WaterVtab.FindField(\"Value\")\n \nSlopeGrd=ElevGrd.Slope(NIL,FALSE) 'Construct SlopeGrd\naPrj = theView.GetProjection\n\nr=SlopeGrd.ZonalStats(#GRID_STATYPE_MEAN,WaterGrd,aPrj,\n WaterFld,FALSE)\n\n'check if output is ok\nif (r.HasError) then \n return NIL \nelse\n return r\nend\n\n" ) (Script.113 Name: "Hydro.dd.Open" SourceCode: "\nTheDialog=SELF\ncbox = TheDialog.Findbyname(\"cbx_Themes\")\ncbox.update\n\ncboWsh=TheDialog.FindByName(\"cboWatershed\")\ncboWsh.Update\n\nlblWatershed = TheDialog.FindByName(\"lblAttribute\")\nlblWatershed.Update\n\noptDEM=TheDialog.FindByName(\"optDEM\")\noptDEM.Select\noptDEM.Click\n\nfor each cn in TheDialog.GetControlPanel\n cn.SetEnabled(True)\nend\n\ncbox.SetListeners({lblWatershed})\n'When entering the Dialog, OptDEM is selected, so the cboWatershed is disabled.\nav.run(\"Hydro.dd.ChkBoxes.Checked\",{TheDialog,True})\nav.run(\" Hydro.dd.Watershed.Enabled\",{TheDialog,False}) 'Disable the cboWater,lblWater.\n" ) (Script.114 Name: "Hydro.dd.OptDem_Click" SourceCode: "'*****************************************\n' Name: Hydro.dd.OptDem_Click\n' Headline: \n' Self: RadioButton\n' Returns: \n' Description: Setup controls for DEM related\n' operation. \n' Topics:\n' Search Keys:\n' Requires:\n' History:\n'*****************************************\nTheDialog=SELF.GetDialog\n'Disable the Predefined watershed, and enable the DEM\nav.run(\"Hydro.dd.Watershed.Enabled\",{TheDialog,True})\nbtnOK=TheDialog.FindByName(\"btn_OK\")\ncboDEM=TheDialog.FindByName(\"cbx_Themes\")\nif(cboDEM.GetRowCount>0)then\n btnOK.SetEnabled(True)\nelse\n btnOK.SetEnabled(False)\nend\nav.run(\"Hydro.dd.Watershed.Enabled\",{TheDialog,False}) 'Disable the cboWater,lblWater.\nav.run(\"Hydro.dd.chkBoxes.Enabled\",{TheDialog,True}) \n " ) (Script.115 Name: "Hydro.dd.OptWatershed_Click" SourceCode: "'*****************************************\n' Name: Hydro.dd.OptWatershed_Click\n' Headline: \n' Self: RadioButton\n' Returns: \n' Description: Setup controls for Pre-Defined\n' Watershed related operation. \n' Topics:\n' Search Keys:\n' Requires:\n' History: 9/3\n'*****************************************\nTheDialog=SELF.GetDialog\n'When there is not Tag on the CurrentThm on cboWatershed, disable\n'the river related operation, i.e. stream flow length.\nTheView=av.GetActiveDoc\ncboWatershed=TheDialog.FindByName(\"cboWaters hed\")\ncboDEM=TheDialog.FindByName(\"cbx_Themes\")\nbtnOK=TheDialog.FindByName(\"btn_OK\")\nif((cboWatershed.GetRowCount>0) and (cboDEM.GetRowCount>0))then\n btnOK.SetEnabled(True)\n av.run(\"Hydro.dd.Watershed.Enabled\",{TheDialog,True})\n av.Run(\"Hydro.dd.ChkBoxes.Enabled\",{TheDialog,False})\nelse\n optDEM=TheDialog.FindByName(\"optDEM\")\n optDEM.Click\n optDEM.Update\nend\n" ) (Script.116 Name: "Hydro.dd.Startup" SourceCode: "av.FindDialog(\"Hydro\").open\nav.FindDialog(\"Hydro\").moveto(90,90)" ) (Script.117 Name: "Hydro.dd.Watershed" SourceCode: "'*****************************************\n' Name: Hydro.dd.watershed\n' Headline: \n' Self:\n' Returns: \n' Description: Construct Watershed and attached\n' a dictionary containing The files that will\n' be used by Hydro.dd.btn.OK.click.\n' The dictionary:\n' Key Content 'c:\\windows\\temp=av.getProject.getWorkDir\n' elev c:\\windows\\temp\\elev1 'elev1,fdir1,riv1,ppnt1, are The FNs of The grids.\n' fdir c:\\windows\\temp\\fdir1 'flow direction grd.\n' riv c:\\windows\\temp\\riv1 'river grd.\n' ppnt c:\\windows\\temp\\ppnt1 'pourpnt grd. \n' Topics:\n' Search Keys:\n' Requires: Elevation Grd.\n' History: 9/2\n'*****************************************\nTheView=SELF.Get(0)\nTheDialog=SELF.Get(1)\nTheWorkDir=SELF.Get(2)\nTheFileDict=Dictionary.Make(5)\nelevKey=\"elev\"\nppntKey=\"ppnt\"\nfdirKey=\"fdir\"\nrivKey=\"riv\"\nwaterKey=\"water\"\n\nif(TheView.Is(View).Not)then\n msgbox.info(TheView.GetName++\"is not a View\"+nl+\"Make a view active\",Script.The.GetName)\n exit\nend\n\n'Get The selected Theme in The com bo box\nTheTheme=TheDialog.FindByName(\"cbx_Themes\").GetCurrentValue\nTheThemeName = TheTheme.Getname.Clone\n\n'Create a flow direction grid\nelevGrid = TheTheme.GetGrid\n\nTheFlowDirGrd = elevGrid.FlowDirection(FALSE)\n \n\n'Check for Sinks on The currently selected elevation grid's direction grid\nTheSinkGrid = TheFlowDirGrd.Sink\n \nif ((TheSinkGrid.getVTab = NIL).Not) Then \n\n 'YesNo to fill sinks\n fillStat = MsgBox.YesNo(TheSinkGrid.GetVTab.GetSelection.GetSize.AsString++ \n \"Sinks were identified!\"+nl+\"\"+NL+\n \"Do you want to fill The sinks?\",\n \"Hydrologic Modeling\",true) \n 'Fill sinks\n if(fillStat.not)Then\n return nil\n else\n '*****************************************From Hydro.Fill************************\n ' fill sinks in Grid until They are gone\n sinkCount = 0\n numSinks = 0\n while (TRUE)\n \n if (TheSinkGrid.GetVTab = NIL) Then\n ' check for errors\n if (TheSinkGrid.Ha sError) Then return NIL end\n TheSinkGrid.BuildVAT\n end\n ' check for errors\n if (TheSinkGrid.HasError) Then return NIL end\n if (TheSinkGrid.GetVTab <> NIL) Then\n TheVTab = TheSinkGrid.GetVTab\n numClass = TheVTab.GetNumRecords\n newSinkCount = TheVTab.ReturnValue(TheVTab.FindField(\"Count\"),0)\n else\n numClass = 0\n newSinkCount = 0\n end\n if (numClass < 1) Then\n break\n elseif ((numSinks = numClass) and (sinkCount = newSinkCount)) Then\n break\n end\n waterGrid = TheFlowDirGrd.Watershed(TheSinkGrid)\n zonalFillGrid = waterGrid.ZonalFill(elevGrid)\n fillGrid = (elevGrid < (zonalFillGrid.IsNull.Con(0.AsGrid,zonalFillGrid))).Con(zonalFillGrid,elevGrid)\n elevGrid = fillGrid\n numSinks = numClass\n sinkCount = newSinkCount\n end\n '*****************************************End From Hydro.Fill************************\n end 'fillStat\nend 'Check for no sinks \n\n'Create a watershed\n\nelevName=TheWorkDir.MakeTmp(\"elev\",\"\") \nelevGrid.ReName(elevName)\nTheFileDict.Add(elevKey,elevGrid) 'elevName added.\n\n' Create new flow direction grid\nTheFlowDirGrd = elevGrid.FlowDirection(FALSE)\nfdirName=TheWorkDir.MakeTmp(\"fdir\",\"\")\nTheFlowDirGrd.ReName(fdirName)\nTheFileDict.Add(fdirKey,TheFlowDirGrd) 'fdirName added.\n\n' Create a flow accumulation grid\nTheFlowAccGrid = TheFlowDirGrd.FlowAccumulation(NIL)\n\n'*****************************************From Hydro.Watershed** **********************\n'if not ComputeAttribute, the While(not ComputeAttribute) loop will continue to\n'ask for new threshold to get new watershed delineated based on the Filled DEM,\n'FlowDir, and FlowAcc computed above. If ComputeAttribute=True, the while loop \n'will end and a dictionary is sent back to the calling program, hydro.dd.btn_OK.Click\n'9/27/97\n'*************************************************************************************\nComputeAttribute=False\nWhile(ComputeAttribute.Not)\n status = TRUE \n while (status)\n minSize = MsgBox.Input(\"Enter the minumum number of cells to define a watershed.\", \n \"Watershed Delineation\", \"500\")\n if (minSize = NIL) Then return NIL end\n if ((minSize.IsNumber) and (minSize.AsNumber > 0)) Then\n status = FALSE\n else\n status = TRUE\n MsgBox.Error(\"The minimum watershed size must be a number greater than 0\",\"Watershed Delineation\")\n end\n end \n\n ' create stream net\n r = (TheFlowAccGrid < minSize.AsNumber.AsGrid).Set Null(1.AsGrid)\n\n\n ' create watersheds\n r2 = r.StreamLink(TheFlowDirGrd) \n rivName=TheWorkDir.MakeTmp(rivKey,\"\")\n r2.ReName(rivName)\n TheFileDict.Add(rivKey,r2) 'rivName added.\n\n '..construct PourPoint Grid.\n MaxGrd=TheFlowAccGrid.ZonalStats(#GRID_STATYPE_MAX,r2,\n TheView.GetProjection,\n r2.getVtab.FindField(\"Value\"),\n False)\n\n ThePourGrd=(MaxGrd<>TheFlowAccGrid).SetNull(r2)\n ppntName=The WorkDir.MakeTmp(ppntKey,\"\")\n ThePourGrd.ReName(ppntName)\n TheFileDict.Add(ppntKey,ThePourGrd) 'ppntName added. \n\n r3 = TheFlowDirGrd.Watershed(r2)\n ' rename data set\n aFN = av.GetProject.GetWorkDir.MakeTmp(\"watr\", \"\")\n r3.Rename(aFN)\n TheFileDict.Add(WaterKey,r3) 'Adding watershedGrd to Dict.\n ' check if output is ok\n if (r3.HasError) Then return NIL end\n\n ' create a Theme \n gthm = GTheme.Make(r3) \n\n ' set name of Theme\n gthm.SetName(\"Watersheds of\"++TheThemeName)\n\n ' Add Theme to The specified View\n TheView.AddTheme(gthm)\n gthm.SetVisible(True)\n TheView.GetDisplay.Flush\n 'Ask if user want to continue to compute the attributes.\n ComputeAttribute=Msgbox.YesNoCancel(\"Use the delineated watershed for further analysis ?\"+nl+\"(Select No to change the threshold for watershed delineation)\",\n Script.The.GetName,True)\n if(ComputeAttribute=nil)then\n exit\n end\n if(not ComputeAttribute)then\n TheFileDict.Remove(WaterKey)\n TheFileDict.Remove(ppntKey)\n TheFileDict.R emove(rivKey)\n TheView.DeleteTheme(gthm)\n end \nend\n\nReturn TheFileDict\n'*****************************************End From Hydro.Watershed************************\nmsgbox.info(\"Watershed Delineation Is Completed.\",Script.The.GetName)\n\n'Get handles to all the chk boxes.\n'lblAttrb=TheDialog.FindByName(\"lblAttribute\")\n'lblAttrb.SetEnabled(True)\n\n'for each cn in TheDialog.GetControlPanel\n' 'msgbox.info(cn.GetName,\"\")\n' if(cn.GetClass.GetClassName=\"CheckBox\")then\n' cn.SetEnabled(True)\n' cn.SetSele cted(False)\n' end\n' if (cn.GetName = \"btn_OK\") Then\n' cn.SetObjectTag(gthm.GetName)\n' cn.SetEnabled(False)\n' elseif(cn.GetName=\"btn_WatershedDelineate\")Then\n' cn.SetTag(TheTheme.GetName) 'TheTheme is The ElevationThm.\n' end \n'end\n\n\n'SELF.BroadCastUpdate" ) (Script.118 Name: "Hydro.dd.Watershed.Enabled" SourceCode: "'*****************************************\n' Name: Hydro.dd.Watershed.Enabled\n' Headline: \n' Self: {TheDialog,True/False}\n' Returns: \n' Description: Called by OptDEM/OptWatershed\n' to enable/disabled the DEM/Pre-defined watershed\n' Controls.\n' When SELF=True, PredefinedWatershed's controls\n' are turned on and DEM's Controls are turned off.\n' Topics:\n' Search Keys:\n' Requires:\n' History: 9/03\n'*****************************************\nTheDialog=SELF.Get(0)\nblnEnabled=SELF.Get(1)\n\n'Set Predefined watershe d controls.\nlblWatershed=TheDialog.FindByName(\"lblWatershed\")\nlblWatershed.SetEnabled(blnEnabled)\ncboWatershed=TheDialog.FindByName(\"cboWatershed\")\ncboWatershed.SetEnabled(blnEnabled)\n\n'Set DEM related controls.\nlblDEM=TheDialog.FindByName(\"lblDEM\")\nlblDEM.SetEnabled(True)\ncboDEM=TheDialog.FindByName(\"cbx_Themes\")\ncboDEM.SetEnabled(True)\n" ) (Script.119 Name: "Hydro.Fill" SourceCode: "' Fill sink script\n'\n' Active theme: Elevation surface\n\ntheView = av.GetActiveDoc\n\n' fill active GTheme\ntheTheme = theView.GetActiveThemes.Get(0)\n\n' fill sinks in Grid until they are gone\nelevGrid = theTheme.GetGrid\nsinkCount = 0\nnumSinks = 0\nwhile (TRUE)\n flowDirGrid = elevGrid.FlowDirection(FALSE)\n sinkGrid = flowDirGrid.Sink\n if (sinkGrid.GetVTab = NIL) then\n ' check for errors\n if (sinkGrid.HasError) then return NIL end\n sinkGrid.BuildVAT\n end\n ' check for errors\n if (sinkGrid.HasError) then return NIL end\n if (sinkGrid.GetVTab <> NIL) then\n theVTab = sinkGrid.GetVTab\n numClass = theVTab.GetNumRecords\n newSinkCount = theVTab.ReturnValue(theVTab.FindField(\"Count\"),0)\n else\n numClass = 0\n newSinkCount = 0\n end\n if (numClass < 1) then\n break\n elseif ((numSinks = numClass) and (sinkCount = newSinkCount)) then\n break\n end\n waterGrid = flowDirGrid.Watershed(sinkGrid)\n zonalFillGrid = waterGrid.ZonalFill(elevGrid)\n fillGrid = (elevGrid < (zonalFillGrid.IsNull.Con(0.A sGrid,zonalFillGrid))).Con(zonalFillGrid,elevGrid)\n elevGrid = fillGrid\n numSinks = numClass\n sinkCount = newSinkCount\nend\n\n' rename data set\naFN = av.GetProject.GetWorkDir.MakeTmp(\"fill\", \"\")\nelevGrid.Rename(aFN)\n\n' create a theme \ntheGTheme = GTheme.Make(elevGrid) \n\n' set name of theme\ntheGTheme.SetName(\"Filled\"++theTheme.GetName)\n\n' add theme to the view\ntheView.AddTheme(theGTheme)\nReturn elevGrid" ) (Script.120 Name: "Hydro.FlowAccumulation" SourceCode: "' Accumulation script\n'\n' Active theme: Flow Direction\n\ntheView = av.GetActiveDoc\nt = theView.GetActiveThemes.Get(0)\ng = t.GetGrid\nr = g.FlowAccumulation(NIL)\n\n' rename data set\naFN = av.GetProject.GetWorkDir.MakeTmp(\"facc\", \"\")\nr.Rename(aFN)\n\n' check if output is ok\nif (r.HasError) then return NIL end\n\n' create a theme \ngthm = GTheme.Make(r) \n\n' set name of theme\ngthm.SetName(\"Flow Accumulation\")\n\n' add theme to the view\ntheView.AddTheme(gthm)\n\n\n\n\n\n\n\n\n\n\n\n\n\n" ) (Script.121 Name: "Hydro.FlowDirection" SourceCode: "' Flow Direction script\n'\n' Active theme: Elevation surface\n\ntheView = av.GetActiveDoc\nt = theView.GetActiveThemes.Get(0)\ng = t.GetGrid\nr = g.FlowDirection(FALSE)\n\n' rename data set\naFN = av.GetProject.GetWorkDir.MakeTmp(\"fdir\", \"\")\nr.Rename(aFN)\n\n' check if output is ok\nif (r.HasError) then return NIL end\n\n' create a theme \ngthm = GTheme.Make(r) \n\n' set name of theme\ngthm.SetName(\"Flow Direction\")\n\n' add theme to the specifiedView\ntheView.AddTheme(gthm)" ) (Script.122 Name: "Hydro.FlowDistance" SourceCode: "' Flow distance script\n'\n' Active theme: Watershed\n' User selects theme: Flow Direction\n\ntheView = av.GetActiveDoc\nt = theView.GetActiveThemes.Get(0)\ng = t.GetGrid\n'Get the grid theme table\nzoneObj = t.GetVTab\n\n'get zone Field from zoneObj\nzoneField = zoneObj.FindField(\"Value\")\n\n'make sure the list contains only grid themes\ngridThemeList = {}\nfor each thm in theView.GetThemes\n if (thm.Is(GTHEME).Not) then\n Continue\n else\n gridThemeList.Add(thm)\n end \nend\n\n' get value theme\nvalueTheme = Msg Box.Choice(gridThemeList,\n \"Please select a Flow Direction theme\",\"Hydro\")\n if (valueTheme = NIL) then Return NIL end\n\n' upstream or downstream\nupStream = MsgBox.YesNo(\"Calculate length to an outlet?\",\"Flow Length\",TRUE)\nx = valueTheme.GetGrid.FlowLength(NIL, upStream)\n\n' obtain grid from value theme and create VTab\n\ntheGrid = x\naPrj = theView.GetProjection\nrzm = theGrid.ZonalStats(#GRID_STATYPE_MAX,\n g,\n aPrj,\n zoneField,\n FALSE)\n\nr = rzm\n\n' rename data set\naFN = av.GetProject.GetWorkDir.MakeTmp(\"fdst\", \"\")\nr.Rename(aFN)\n\n' check if output is ok\nif (r.HasError) then return NIL end\n\n' create a theme \ngthm = GTheme.Make(r) \n\n' set name of theme\ngthm.SetName(\"Maximum Flow Distance\")\n\n' add theme to the view\ntheView.AddTheme(gthm)\n\n" ) (Script.123 Name: "Hydro.FlowLength" SourceCode: "' Flow Length script\n'\n' Active theme: Flow Direction \n\ntheView = av.GetActiveDoc\nt = theView.GetActiveThemes.Get(0)\ng = t.GetGrid\n\n' upstream or downstream\nupStream = MsgBox.YesNo(\"Calculate length to an outlet?\",\"Flow Length\",TRUE)\nr = g.FlowLength(NIL, upStream)\n\n' rename data set\naFN = av.GetProject.GetWorkDir.MakeTmp(\"flen\", \"\")\nr.Rename(aFN)\n\n' check if output is ok\nif (r.HasError) then return NIL end\n\n' create a theme \ngthm = GTheme.Make(r) \n\n' set theme name\nif (upStream) then\n gthm.SetName(\"Upst ream Flow Length\")\nelse\n gthm.SetName(\"Downstream Flow Length\")\nend\n\n' add theme to the view\ntheView.AddTheme(gthm)" ) (Script.124 Name: "Hydro.GetInGrds" SourceCode: "'*************************************\n' Name: Hydro.GetInGrds\n' Headline: \n' Self: {WatershedTheme}\n' Returns: Dictionary of InGrds.\n' or nil on Error.\n' The contents of TheGrdDict:\n' Key Contents\n' elev ElevGrd\n' fdir FdirGrd\n' riv RivGrd\n' ppnt PourPointGrd\n' \n' Description: Based on the Dictionary \n' Tagged on the thm to get the input grids \n' for hydro.Analysis.\n' Topics: Hydro.\n' Search Keys: \n' Requires: \n' History: 8/18/97\n'**************************************\nTheDict=SE LF.GetObjectTag\nif(TheDict.Is(Dictionary).Not)then\n return nil\nend\n\nTheGrdDict=Dictionary.Make(4)\nfor each i in TheDict.ReturnKeys\n aGrd=Grid.Make(Grid.MakeSrcName(TheDict.Get(i)))\n if(aGrd.HasError)then\n 'msgbox.info(\"Grid Error on Grid with its key of\"++i.asString,Script.The.GetName)\n return nil\n else\n TheGrdDict.Add(i,aGrd)\n end\nend\n \nReturn TheGrdDict\n\n " ) (Script.125 Name: "Hydro.GetInThms" SourceCode: "'*************************************\n' Name: Hydro.GetInThms \n' Headline: \n' Self: {TheView,{InTags}} \n' Returns: {InThms} or nil on Error.\n' Description: Get the input Themes for hydro.Analysis.\n' Topics: Hydro.\n' Search Keys: \n' Requires: \n' History: 8/22/97\n'**************************************\nTheView=SELF.Get(0) 'ViewHandle.\nTheTags=SELF.Get(1) 'TagList.\n\nTheThms=List.Make\nNameList=List.Make\n\nViewThms=TheView.GetThemes\n\nfor each theTag in TheTags\n TagFound=False\n for each Thm in ViewThms\n if(Thm.GetObjectTag=theTag)then\n if(Thm.Is(GTheme))then\n TagFound=True\n TheName=Thm.GetName\n break\n end\n end\n end 'for each thm.\n if(TagFound)then\n NameList.Add(theName)\n else\n TheThm=Msgbox.ChoiceAsString(ViewThms,\"Select a Theme for\"++theTag,Script.The.GetName)\n if(TheThm.Is(GTheme))then\n NameList.Add(TheThm.GetName)\n else\n TheThms=Nil\n break\n end\n end\nend \nif (TheThms<>nil) then \n for each aName in NameList\n TheThms.Add(theV iew.FindTheme(aName))\n end\nend \n\nreturn TheThms" ) (Script.126 Name: "hydro.GetPolyLineLength" SourceCode: "'*****************************************\n' Name: hydro.GetPolyLineLength\n' Headline: \n' Self: PolyLine\n' Returns: Length of the PolyLine\n' Description: Calculate the length of a Polyline. \n' Requires:\n' History: 7/6/97\n'*****************************************\narcIn=SELF\nsegList=arcIn.AsList\nTheLength=0\nfor each lst in SegList\n isFirstPoint=True\n SegLength=0\n for each pnt in lst\n if(isFirstPoint)then\n OldPnt=Pnt\n isFirstPoint=False\n else\n SegLength=SegLength+((((Pnt.getX-OldPnt.ge tX)^2)+((Pnt.getY-OldPnt.getY)^2))^(0.5))\n OldPnt=Pnt.Clone\n end\n end\n TheLength=TheLength+SegLength\nend \nreturn (TheLength)\n\n\n'' 55. c:\\tnrcc\\aveprog\\hydro.GetPolyLineLength of 31 lines,\n" ) (Script.127 Name: "hydro.GetThms" SourceCode: "'*****************************************\n' Name: hydro.GetThms, Active or All.\n' Headline: \n' Self: {TheView,ThmAct,ThmType,ShpType}\n' ThmAct=True, for active thms, False, all thms.\n' ThmType=[FTheme,GTheme,DbTheme]\n' ShpType=[Poly,Line,Point,Mpoint]\n' Returns: \n' Description: Get Thms of specified type. \n' Topics:\n' Search Keys:\n' Requires:\n' History: 4/1/97\n'*****************************************\nTheView=SELF.Get(0)\nThmAct=SELF.Get(1) 'Active/ALL, Boolean.\nThmType=SELF.Get(2) 'GTheme,FTheme or o thers.\nInfoTitle=\"Theme Identification\"\nIsFThm=False\nThmTypeName=ThmType.GetClassName\nif(ThmTypeName=\"FTheme\")then\n ShpType=SELF.Get(3) \n IsFThm=True\n if(ShpType=\"POLY\")then\n ShpTypeEnum=\"#FIELD_SHAPEPOLY\".AsEnum\n elseif(ShpType=\"LINE\")then\n ShpTypeEnum=\"#FIELD_SHAPELINE\".AsEnum\n elseif(ShpType=\"POINT\")then\n ShptypeEnum=\"#FIELD_SHAPEPOINT\".AsEnum \n elseif(ShpType=\"MPOINT\")then\n ShpTypeEnum=\"#FIELD_SHAPEMULTIPOINT\".AsEnum \n else \n msgbox.info(\"Use POLY,LINE,POINT or MPOINT as 3rd ar gument\",InfoTitle)\n return nil \n end \nend\nif(ThmAct)then\n TheThms=TheView.GetActiveThemes\nelse \n TheThms=TheView.GetThemes\nend \nif(theThms.Count=0)then\n msgbox.info(\"No active themes found in the view:\"++TheView.GetName,InfoTitle)\n return nil\nend\nThmList=List.Make\nfor each Thm in TheThms\n if(Thm.Is(ThmType))then\n if(IsFthm)then 'for an FTheme, further chk its shape type\n FType=Thm.GetFtab.FindField(\"Shape\").GetType\n if(FType=ShpTypeEnum)then\n ThmList.Add(Thm)\n end \n else\n ThmList.Add(Thm)\n end \n end\nend \nif(ThmList.Count=0)then\n if(ThmAct)then\n msgbox.info(\"No Active\"++ThmTypeName++\"theme is found in the view:\"++TheView.GetName,InfoTitle)\n else\n msgbox.info(\"No\"++ThmTypeName++\"is found in the view:\"++TheView.GetName,InfoTitle)\n end\n return nil\nelse\n return ThmList 'Normal return\nend\n \n\n\n'' 56. c:\\tnrcc\\aveprog\\hydro.GetThms of 70 lines,\n" ) (Script.128 Name: "Hydro.IdentifySinks" SourceCode: "' Identify Sink script\n'\n' Active theme: Flow Direction\n'\n\ntheView = av.GetActiveDoc\nt = theView.GetActiveThemes.Get(0)\ng = t.GetGrid\nr = g.Sink\n\n'Find out how many sinks were identified\nif (r.getVTab = NIL) then \n MsgBox.Info(\"No Sinks were identified!\",\"Identify Sinks\") \n Return NIL \nEnd\n\nif (MsgBox.YesNo(r.GetVTab.GetSelection.GetSize.AsString++ \n \"Sinks were identified!\"+nl+\"\"+NL+\n \"Do you want the Sink theme \"+NL+\"added to the Current View?\",\n \"Identify Si nks\",true).NOT) then\n Return NIL\nelse\n\n' rename data set\naFN = av.GetProject.GetWorkDir.MakeTmp(\"fdir\", \"\")\nr.Rename(aFN)\n\n' check if output is ok\nif (r.HasError) then return NIL end\n\n' create a theme \ngthm = GTheme.Make(r) \n\n' set name of theme\ngthm.SetName(\"Sinks of\"++t.GetName)\n\n' add theme to the specifiedView\ntheView.AddTheme(gthm)\n\nend\n" ) (Script.129 Name: "Hydro.MeanElevation" SourceCode: "' Mean elevation script\n'\n' Active theme: Watershed\n' User selects theme: Elevation\n\ntheView = av.GetActiveDoc\nt = theView.GetActiveThemes.Get(0)\ng = t.GetGrid\n\n'Get the grid theme table\nzoneObj = t.GetVTab\n\n'get zone Field from zoneObj\nzoneField = zoneObj.FindField(\"Value\")\n\n'make sure the list contains only grid themes\ngridThemeList = {}\nfor each thm in theView.GetThemes\n if (thm.Is(GTHEME).Not) then\n Continue\n else\n gridThemeList.Add(thm)\n end \nend\n\n' get value theme\nvalueTheme = MsgBox .Choice(gridThemeList,\n \"Please Select an Elevation Theme\",\"Hydro\")\nif (valueTheme = NIL) then Return NIL end\n\n' obtain grid from value theme and create VTab\ntheGrid = valueTheme.GetGrid\naPrj = theView.GetProjection\nr = theGrid.ZonalStats(#GRID_STATYPE_MEAN,\n g,\n aPrj,\n zoneField,\n FALSE)\n\n' rename data set\naFN = av.GetProject.GetWorkDir.MakeTmp(\"ar ea\", \"\")\nr.Rename(aFN)\n\n' check if output is ok\nif (r.HasError) then return NIL end\n\n' create a theme \ngthm = GTheme.Make(r) \n\n' set name of theme\ngthm.SetName(\"Mean Elevation\")\n\n' add theme to the specifiedView\ntheView.AddTheme(gthm)" ) (Script.130 Name: "Hydro.MeanPrecipitation" SourceCode: "' Mean Precipitation script\n'\n' Active theme: Watershed\n' User selects theme: Precipitation\n\ntheView = av.GetActiveDoc\nt = theView.GetActiveThemes.Get(0)\ng = t.GetGrid\n\n'Get the grid theme table\nzoneObj = t.GetVTab\n\n'get zone Field from zoneObj\nzoneField = zoneObj.FindField(\"Value\")\n\n'make sure the list contains only grid themes\ngridThemeList = {}\nfor each thm in theView.GetThemes\n if (thm.Is(GTHEME).Not) then\n Continue\n else\n gridThemeList.Add(thm)\n end \nend\n\n' get value theme\nvalueTheme = MsgBox.Choice(gridThemeList,\n \"Please Select a Precipitation Theme\",\"Hydro\")\n if (valueTheme = NIL) then Return NIL end\n\n' obtain grid from value theme and create VTab\ntheGrid = valueTheme.GetGrid\naPrj = theView.GetProjection\nr = theGrid.ZonalStats(#GRID_STATYPE_MEAN,\n g,\n aPrj,\n zoneField,\n FALSE)\n' rename data set\naFN = av.GetProject.GetWorkDir.MakeTmp(\"prcp\", \"\")\nr.Rename(aFN)\n\n' check if output is ok\nif (r.HasError) then return NIL end\n\n' create a theme \ngthm = GTheme.Make(r) \n\n' set name of theme\ngthm.SetName(\"Mean Precipitation\")\n\n' add theme to the specifiedView\ntheView.AddTheme(gthm)" ) (Script.131 Name: "Hydro.MeanSlope" SourceCode: "' Mean slope script\n'\n' Active theme: Watershed\n' User selects theme: Slope\n\ntheView = av.GetActiveDoc\nt = theView.GetActiveThemes.Get(0)\ng = t.GetGrid\n\n'Get the grid theme table\nzoneObj = t.GetVTab\n\n'get zone Field from zoneObj\nzoneField = zoneObj.FindField(\"Value\")\n\n'make sure the list contains only grid themes\ngridThemeList = {}\nfor each thm in theView.GetThemes\n if (thm.Is(GTHEME).Not) then\n Continue\n else\n gridThemeList.Add(thm)\n end \nend\n\n' get value theme\nvalueTheme = MsgBox.Choice( gridThemeList,\n \"Select a Slope Theme\",\"Hydro\")\n if (valueTheme = NIL) then Return NIL end\n\n' obtain grid from value theme and create VTab\ntheGrid = valueTheme.GetGrid\naPrj = theView.GetProjection\nr = theGrid.ZonalStats(#GRID_STATYPE_MEAN,\n g,\n aPrj,\n zoneField,\n FALSE)\n\n' rename data set\naFN = av.GetProject.GetWorkDir.Ma keTmp(\"slop\", \"\")\nr.Rename(aFN)\n\n' check if output is ok\nif (r.HasError) then return NIL end\n\n' create a theme \ngthm = GTheme.Make(r) \n\n' set name of theme\ngthm.SetName(\"Mean Slope\")\n\n' add theme to the specifiedView\ntheView.AddTheme(gthm)" ) (Script.132 Name: "Hydro.OneActiveGridUpdate" SourceCode: "' FillUpdate script\n\ntheView = av.GetActiveDoc\nenabled = FALSE\n\n' enable if the active theme is a grid theme\nif (theView.GetActiveThemes.Count = 1) then\n if (theView.GetActiveThemes.Get(0).Is(GTHEME)) then\n enabled = TRUE\n end\nend\nSELF.SetEnabled(enabled)\n\n\n" ) (Script.133 Name: "Hydro.OneActiveIntGridUpdate" SourceCode: "' AccumulationUpdate script\n\ntheView = av.GetActiveDoc\nenabled = FALSE\n\n' enable if the active theme is a grid theme\nif (theView.GetActiveThemes.Count = 1) then\n if (theView.GetActiveThemes.Get(0).Is(GTHEME) and\n theView.GetActiveThemes.Get(0).GetGrid.IsInteger) then\n enabled = TRUE\n end\nend\nSELF.SetEnabled(enabled)\n" ) (Script.134 Name: "Hydro.PourPoint" SourceCode: "' Identify pour points script\n'\n' Active theme: Watershed\n' User selects theme: Flow Accumulation\n\ntheView = av.GetActiveDoc\nt = theView.GetActiveThemes.Get(0)\ng = t.GetGrid\n\n'Get the grid theme table\nzoneObj = t.GetVTab\n\n'get zone Field from zoneObj\nzoneField = zoneObj.FindField(\"Value\")\n\n'make sure the list contains only grid themes\ngridThemeList = {}\nfor each thm in theView.GetThemes\n if (thm.Is(GTHEME).Not) then\n Continue\n else\n gridThemeList.Add(thm)\n end \nend\n\n' get value theme\nvalue Theme = MsgBox.Choice(gridThemeList,\n \"Please select a Flow Accumulation theme\",\"Hydro\")\n if (valueTheme = NIL) then Return NIL end\n\n' obtain grid from value theme and create VTab\ntheGrid = valueTheme.GetGrid\naPrj = theView.GetProjection\nrzm = theGrid.ZonalStats(#GRID_STATYPE_MAX,\n g,\n aPrj,\n zoneField,\n FALSE)\n \nr = (valueTheme.GetGrid <> rzm).SetNull(g)\nif(r.HasError)then\n return NIL \nend\n \n' rename data set\naFN = av.GetProject.GetWorkDir.MakeTmp(\"ppts\",\"shp\")\npntFtab=r.AsPointFTab (aFN,Prj.MakeNULL)\nAddBasinID=av.run(\"hydro.AddBasinId\",{pntFtab,\"Grid_Code\",\"BasinId\"})\npntFthm=FTheme.Make(pntFtab)\n\n' set name of theme\npntFthm.SetName(\"Pour Points of\"++t.getname)\n\n' add theme to the specifiedView\ntheView.AddTheme(pntFthm)\n\n" ) (Script.135 Name: "Hydro.ResetObj" SourceCode: "'*****************************************\n' Name: hydro.ResetObj\n' Headline: \n' Self:\n' Returns: \n' Description: Removes object-tags \n' Topics:\n' Search Keys:\n' Requires:\n' History: 12/27/96\n'*****************************************\n'--reset objectTag Associated with the Project\nNObj=0\nTheProject=av.getProject\n'TheProject.SetObjectTag(nil)\n\n'reset objectTag assoicated with the View\nTheViewGui=TheProject.FindGui(\"View\")\nif(TheViewGui.GetObjectTag<>nil)then\n TheViewGui.SetObjectTag(nil)\n Nobj=Nobj+1\nend\ni f(TheViewGui<>nil)then\n if(TheViewGui.GetToolBar.GetObjectTag<>nil)then\n TheViewGui.GetToolBar.SetObjectTag(nil)\n Nobj=Nobj+1\n end\n for each m in TheViewGui.GetToolBar\n av.showMsg(\"Number of ObjectTag Cleaned=\"+Nobj.AsString)\n if(m.Is(Space).not)then \n if(m.getObjectTag<>nil)then\n m.SetObjectTag(nil)\n Nobj=Nobj+1 \n end\n if(m.Is(ToolMenu)) then\n for each i in m\n if(i.GetObjectTag<>nil)then\n i.SetObjectTag(nil)\n Nobj=Nobj+1\n end\n end\n end\n end 'if(m.Is(Space).not)\n end ' for each m in TheViewGui.GetToolBar\n \n if(TheViewGUI.getButtonBar.GetObjectTag<>nil)then\n TheViewGui.GetButtonBar.SetObjectTag(nil)\n Nobj=Nobj+1\n end\n \n for each m in TheViewGui.GetButtonBar\n av.ShowMsg(\"Number of ObjectTag Cleaned=\"+Nobj.AsSTring)\n if(m.Is(Space).not)then\n if(m.getObjectTag<>nil)then\n m.setObjectTag(nil)\n Nobj=Nobj+1\n end\n end\n end 'for each m in TheViewGui.G etButtonBar\n \n if(TheViewGui.GetMenuBar.GetObjectTag<>nil)then\n TheViewGui.GetMenuBar.SetObjectTag(nil)\n Nobj=Nobj+1\n end\n \n for each m in TheViewGui.GetMenuBar\n for each i in m\n if(i.Is(SPACE).not)then \n if(m.getObjectTag<>nil)then\n m.setObjectTag(nil)\n Nobj=Nobj+1 \n end \n end\n end \n end 'for each m in TheViewGui.GetMenuBar\nend 'if(TheViewGui<>nil) \n\nTheScriptGui=TheProject.FindGui(\"Script\") 'Script\nif(TheScriptGui<>nil)then\n for each m i n TheScriptGui.GetToolBar\n av.showMsg(\"Number of ObjectTag Cleaned=\"+Nobj.AsString)\n if(m.Is(Space).not)then \n if(m.getObjectTag<>nil)then\n m.SetObjectTag(nil)\n Nobj=Nobj+1 \n end\n if(m.Is(ToolMenu)) then\n for each i in m\n if(i.GetObjectTag<>nil)then\n i.SetObjectTag(nil)\n Nobj=Nobj+1\n end\n end\n end\n end 'if(m.Is(Space).not)\n end ' for each m in TheScriptGui.GetToolBar\n for each m in TheScriptGu i.GetButtonBar\n av.ShowMsg(\"Number of ObjectTag Cleaned=\"+Nobj.AsSTring)\n if(m.Is(Space).not)then\n if(m.getObjectTag<>nil)then\n m.setObjectTag(nil)\n Nobj=Nobj+1\n end\n end\n end 'for each m in TheScriptGui.GetButtonBar\n for each m in TheScriptGui.GetMenuBar\n for each i in m\n if(i.Is(SPACE).not)then \n if(m.getObjectTag<>nil)then\n m.setObjectTag(nil)\n Nobj=Nobj+1 \n end \n end\n end \n end 'for each m in TheScriptGui.GetMen uBar \nend 'if(TheScriptGui<>nil)\n\nTheChartGui=TheProject.FindGui(\"Chart\") 'Chart\nif(TheChartGui<>nil)then\n for each m in TheChartGui.GetToolBar\n av.showMsg(\"Number of ObjectTag Cleaned=\"+Nobj.AsString)\n if(m.Is(Space).not)then \n if(m.getObjectTag<>nil)then\n m.SetObjectTag(nil)\n Nobj=Nobj+1 \n end\n if(m.Is(ToolMenu)) then\n for each i in m\n if(i.GetObjectTag<>nil)then\n i.SetObjectTag(nil)\n Nobj=Nobj+1\n end\n end\n end\n end 'if(m.Is(Space).not)\n end ' for each m in TheChartGui.GetToolBar\n for each m in TheViewGui.GetButtonBar\n av.ShowMsg(\"Number of ObjectTag Cleaned=\"+Nobj.AsSTring)\n if(m.Is(Space).not)then\n if(m.getObjectTag<>nil)then\n m.setObjectTag(nil)\n Nobj=Nobj+1\n end\n end\n end 'for each m in TheChartGui.GetButtonBar\n for each m in TheViewGui.GetMenuBar\n for each i in m\n if(i.Is(SPACE).not)then \n if(m.getObjectTag<>nil)then\n m.se tObjectTag(nil)\n Nobj=Nobj+1 \n end \n end\n end \n end 'for each m in TheChartGui.GetMenuBar \nend 'if(TheChartGui<>nil)\n \nTheTableGui=TheProject.FindGui(\"Table\")\nif(TheTableGui<>nil)then\n for each m in TheTableGui.GetToolBar\n av.showMsg(\"Number of ObjectTag Cleaned=\"+Nobj.AsString)\n if(m.Is(Space).not)then \n if(m.getObjectTag<>nil)then\n m.SetObjectTag(nil)\n Nobj=Nobj+1 \n end\n if(m.Is(ToolMenu)) then\n for each i in m\n if(i.GetObjectTag<>nil)then\n i.SetObjectTag(nil)\n Nobj=Nobj+1\n end\n end\n end\n end 'if(m.Is(Space).not)\n end ' for each m in TheTableGui.GetToolBar\n for each m in TheTableGui.GetButtonBar\n av.ShowMsg(\"Number of ObjectTag Cleaned=\"+Nobj.AsSTring)\n if(m.Is(Space).not)then\n if(m.getObjectTag<>nil)then\n m.setObjectTag(nil)\n Nobj=Nobj+1\n end\n end\n end 'for each m in TheTableGui.GetButtonBar\n for each m in TheTableGui.GetM enuBar\n for each i in m\n if(i.Is(SPACE).not)then \n if(m.getObjectTag<>nil)then\n m.setObjectTag(nil)\n Nobj=Nobj+1 \n end \n end\n end \n end 'for each m in TheTableGui.GetMenuBar \nend 'if(TheTableGui<>nil)\n\nTheLayOutGui=TheProject.FindGui(\"LayOut\")\nif(TheLayOutGui<>nil)then\n if(TheLayOutGui.GetObjectTag<>nil)then\n TheLayoutGui.SetOBjectTag(nil)\n Nobj=Nobj+1\n end\n for each m in TheLayOutGui.GetToolBar\n av.showMsg(\"Number of ObjectTag Cleaned=\"+ Nobj.AsString)\n if(m.Is(Space).not)then \n if(m.getObjectTag<>nil)then\n m.SetObjectTag(nil)\n Nobj=Nobj+1 \n end\n if(m.Is(ToolMenu)) then\n for each i in m\n if(i.GetObjectTag<>nil)then\n i.SetObjectTag(nil)\n Nobj=Nobj+1\n end\n end\n end\n end 'if(m.Is(Space).not)\n end ' for each m in TheLayOutGui.GetToolBar\n for each m in TheLayOutGui.GetButtonBar\n av.ShowMsg(\"Number of ObjectTag Cleaned=\"+Nobj.AsSTri ng)\n if(m.Is(Space).not)then\n if(m.getObjectTag<>nil)then\n m.setObjectTag(nil)\n Nobj=Nobj+1\n end\n end\n end 'for each m in TheLayOutGui.GetButtonBar\n for each m in TheLayOutGui.GetMenuBar\n for each i in m\n if(i.Is(SPACE).not)then \n if(m.getObjectTag<>nil)then\n m.setObjectTag(nil)\n Nobj=Nobj+1 \n end \n end\n end \n end 'for each m in TheLayOutGui.GetMenuBar \nend 'if(TheLayOutGui<>nil)\n\nThePrjGui=TheProject.FindGui(\"Projec t\")\nif(ThePrjGui<>nil)then\n if(ThePrjGui.GetObjectTag<>nil)then\n ThePrjGui.SetObjectTag(nil)\n NObj=Nobj+1\n end\n if(ThePrjGui.GetToolBar.GetObjectTag<>nil)then\n ThePRJGui.GetToolBar.SetObjectTag(nil)\n Nobj=Nobj+1\n end\n for each m in ThePrjGui.GetToolBar\n av.showMsg(\"Number of ObjectTag Cleaned=\"+Nobj.AsString)\n if(m.Is(Space).not)then \n if(m.getObjectTag<>nil)then\n m.SetObjectTag(nil)\n Nobj=Nobj+1 \n end\n if(m.Is(ToolMenu)) then\n for e ach i in m\n if(i.GetObjectTag<>nil)then\n i.SetObjectTag(nil)\n Nobj=Nobj+1\n end\n end\n end\n end 'if(m.Is(Space).not)\n end ' for each m in ThePrjGui.GetToolBar\n for each m in ThePrjGui.GetButtonBar\n av.ShowMsg(\"Number of ObjectTag Cleaned=\"+Nobj.AsSTring)\n if(m.Is(Space).not)then\n if(m.getObjectTag<>nil)then\n m.setObjectTag(nil)\n Nobj=Nobj+1\n end\n end\n end 'for each m in ThePrjGui.GetButtonBar\n for each m in ThePrjGu i.GetMenuBar\n for each i in m\n if(i.Is(SPACE).not)then \n if(m.getObjectTag<>nil)then\n m.setObjectTag(nil)\n Nobj=Nobj+1 \n end \n end\n end \n end 'for each m in ThePrjGui.GetMenuBar \nend 'if(ThePrjGui<>nil)\n\nTheDocs=TheProject.GetDocs\n For each d in TheDocs\n if(d.GetObjectTag<>nil)then\n d.SetObjectTag(nil)\n Nobj=Nobj+1\n end\n if(d.Is(View))then\n for each thm in d.GetThemes\n if(thm.getObjectTag<>nil)then\n thm.SetObj ectTag(nil)\n Nobj=Nobj+1\n end\n end\n for each grf in d.GetGraphics\n if(Grf.GetObjectTag<>nil)then\n Grf.SetObjectTag(nil)\n Nobj=Nobj+1\n end\n end \n end\n end\n'Remove Objecttags from HydroDialog. Not for General use. \nTheDialog=av.FindDialog(\"Hydro\")\n msgbox.info(TheDialog.GetClass.GetClassName,TheDialog.GetName)\n if(TheDialog.GetObjectTag<>nil)then\n TheDialog.SetObjectTag(nil)\n Nobj=Nobj+1\n end\n for each cn in TheDialog.GetControlPa nel\n if(cn.GetObjectTag<>nil)then\n cn.SetObjectTag(nil)\n Nobj=Nobj+1\n end\n if(cn.GetTag<>\"\")then\n cn.SetTag(\"\")\n end \n end \n \nMsgbox.info(\"Number of ObjectTag Cleaned=\"+Nobj.AsString,Script.The.GetName)\n" ) (Script.136 Name: "hydro.SetWorkDir" SourceCode: "'*****************************************\n' Name: hydro.SetWorkDir\n' Headline: \n' Self: nil\n' Returns: nil\n' Description: Set work dir. to \n' TheProject.GetFileName.ReturnDir\\tmp\n' if the directory exist. \n' History: 8/19\n'*****************************************\nTheProject=av.GetProject\nTheDir=TheProject.GetFileName.ReturnDir\nWkDir=FN.Merge(TheDir.AsString,\"tmp\")\nif(WkDir.IsDir)then\n TheProject.SetWorkDir(WkDir)\nend\n" ) (Script.137 Name: "Hydro.ShapeFactor" SourceCode: "' Shape factor script\n'\n' Calculates shape factor by dividing (Basin Length ^ 2 / Basin Area)\n'\n' Active theme: None needed\n' User selects themes: Area theme and Perimeter theme\n\ntheView = av.GetActiveDoc\n\n'make sure the list contains only grid themes\ngridThemeList = {}\nfor each thm in theView.GetThemes\n if (thm.Is(GTHEME).Not) then\n Continue\n else\n gridThemeList.Add(thm)\n end \nend\n\n'Get the Area and Perimeter themes\nareaTheme = MsgBox.Choice(gridThemeList,\n \"Plea se Select an Area Theme\",\"Hydro\")\n if (areaTheme = NIL) then Return NIL end\n \ngridThemeList.RemoveObj(areaTheme)\n\nBasinLenTheme = MsgBox.Choice(gridThemeList,\n \"Please Select a Length Theme\",\"Hydro\")\n if (BasinLenTheme = NIL) then Return NIL\nend \n\n\n'Create a ShapeFactorGrid\nr = (BasinLenTheme.getGrid ^ 2) / areaTheme.GetGrid\n\n' rename data set\naFN = av.GetProject.GetWorkDir.M akeTmp(\"shpf\", \"\")\nr.Rename(aFN)\n\n' check if output is ok\nif (r.HasError) then return NIL end\n\n' create a theme \ngthm = GTheme.Make(r) \n\n' set name of theme\ngthm.SetName(\"Shape Factor\")\n\n' add theme to the specifiedView\ntheView.AddTheme(gthm)\n\n' make list of value themes from available themes\nvalueList = List.Make\nfor each t in theView.GetThemes\n if (t.Is(GTHEME)) then\n valueList.Add(t)\n end\nend\n\nzoneTheme = MsgBox.List(valueList, \"Pick Theme that defines zones:\", \"Summarize Zones\")\n if (zoneTheme = NIL) then return NIL end\n\n' obtain Grid for value theme and create VTab\ntheMaskGTheme = theView.GetExtension(AnalysisEnvironment).GetMask\nif (theMaskGTheme = NIL) then\n g = r\nelse\n g = r.ExtractByMask(theMaskGTheme.GetGrid)\nend\naPrj = theView.GetProjection\nzoneField = BasinLenTheme.getGrid.GetVTab.FindField(\"Value\")\noutFN = av.GetProject.GetWorkDir.MakeTmp(\"zstat\",\"dbf\")\nzt = r.ZonalStatsTable(BasinLenTheme.getGrid, aPrj, zoneField, FALSE, outFN)\nif (zt.HasError) then return NIL end\nzoneTable = Table.Make (zt)\nzoneTable.SetName(\"Stats of \" + gthm.GetName + \" Within Zones of Watershed\")\nzoneTable.GetWin.Activate\n\n\n" ) (Script.138 Name: "Hydro.ShapeFactor.OLD" SourceCode: "' Shape factor script\n'\n' Calculates shape factor by dividing (Watershed Area / Watershed Perimeter)\n'\n' Active theme: None needed\n' User selects themes: Area theme and Perimeter theme\n\ntheView = av.GetActiveDoc\n\n'make sure the list contains only grid themes\ngridThemeList = {}\nfor each thm in theView.GetThemes\n if (thm.Is(GTHEME).Not) then\n Continue\n else\n gridThemeList.Add(thm)\n end \nend\n\n'Get the Area and Perimeter themes\nareaTheme = MsgBox.Choice(gridThemeList,\n \"Please Select an Area Theme\",\"Hydro\")\n if (areaTheme = NIL) then Return NIL end\n \ngridThemeList.RemoveObj(areaTheme)\n\nperimeterTheme = MsgBox.Choice(gridThemeList,\n \"Please Select a Perimeter Theme\",\"Hydro\")\n if (perimeterTheme = NIL) then Return NIL end\n\n'Create a ShapeFactorGrid\nr = areaTheme.getGrid / perimeterTheme.GetGrid\n\n' rename data set\naFN = av.GetProject.GetWork Dir.MakeTmp(\"shpf\", \"\")\nr.Rename(aFN)\n\n' check if output is ok\nif (r.HasError) then return NIL end\n\n' create a theme \ngthm = GTheme.Make(r) \n\n' set name of theme\ngthm.SetName(\"Shape Factor\")\n\n' add theme to the specifiedView\ntheView.AddTheme(gthm)" ) (Script.139 Name: "Hydro.StreamNetwork" SourceCode: "'*******************************************\n' Stream Network script\n'\n' Active theme: Flow accumulation\n' User inputs: Minimum number of cells\n' FlowDirection Grid.\n'*******************************************\ntheView = av.GetActiveDoc\nt = theView.GetActiveThemes.Get(0)\ng = t.GetGrid\n\n'Get the grid theme table\nzoneObj = t.GetVTab\n\n' get minimum size\nstatus = TRUE\nwhile (status)\n minSize = MsgBox.Input(\"Enter the minimum number of\"+NL+ \n \"cells for a Stream Network :\", \"Stream Network\", \"100\")\n if (minSize = NIL) then return NIL end\n if (minSize.IsNumber and (minSize.AsNumber > 0)) then\n status = FALSE\n else\n status = TRUE\n MsgBox.Error(\"The minimum Stream Network size must be a number greater than 0\",\n \"Watershed\")\n end\nend \n'Prompt for flow direction theme. zye 10/4\nTheThms=av.run(\"hydro.GetThms\",{TheView,false,GTheme})\nTheFdirThm=msgbox.ChoiceAsString(TheThms,\"Select the flow direction grid theme\",Script.The.GetName)\nif(TheFdirThm=nil) then\n exit\nend\nTheFdirGrd=TheFdirThm.GetGrid\n\n\n' create stream net\nrTmp = (g < minSize.AsNumber.AsGrid).SetNull(1.AsGrid)\nr=rTmp.streamLink(TheFdirGrd)\n\n' rename data set\naFN = av.GetProject.GetWorkDir.MakeTmp(\"str\", \"\")\nr.Rename(aFN)\n\n' check if output is ok\nif (r.HasError) then return NIL end\n\nOutShpFN=av.GetProject.GetWorkDir.MakeTmp(\"riv\",\"shp\")\n\n'TheFtab=r.AsPolyLineFtab(OutShpFN,False,True,prj.MakeNull)\nTheFtab=r.StreamToPolyLineFTab(OutShpFN,TheFdirGrd,False,prj.MakeNull)\nTheFtab.SetEditable(True)\nT heLengFld=TheFtab.FindField(\"length\")\nif(TheLengFld=nil)then\n TheLengFld=Field.Make(\"length\",#FIELD_DECIMAL,14,11)\n TheFtab.AddFields({TheLengFld})\nend \nTheShpFld=TheFtab.FindField(\"Shape\")\n'Calculate the length of a river line.\nfor each rec in TheFtab\n TheShpV=TheFtab.ReturnValue(TheShpFld,rec)\n TheLengV=av.run(\"hydro.GetPolyLineLength\",TheShpV)\n TheFtab.SetValue(TheLengFld,rec,TheLengV) \nend \n'Attach BasinId field\nAddBasinID=av.run(\"hydro.AddBasinId\",{TheFtab,\"Grid_Code\",\"BasinId\"})\n\nTheFThm=FTheme .Make(TheFtab)\nTheView.AddTheme(TheFThm)\nTheFThm.SetName(\"Stream Network Shape - (\"+minSize+\")\")\n\n\n" ) (Script.140 Name: "Hydro.Unload" SourceCode: "\n\nDialog.DetachFromExtension (SELF)" ) (Script.141 Name: "Hydro.Watershed" SourceCode: "' Watershed script\n'\n' Active theme: Flow accumulation\n' User inputs: Minimum number of cells\n' Flow Direction Grid.\n\ntheView = av.GetActiveDoc\nt = theView.GetActiveThemes.Get(0)\ng = t.GetGrid\n\n' get minimum size\nstatus = TRUE\nwhile (status)\n minSize = MsgBox.Input(\"Enter the minimum number of cells for a watershed:\", \n \"Watershed\", \"500\")\n if (minSize = NIL) then return NIL end\n if (minSize.IsNumber and (minSize.AsNumber > 0)) then\n status = FALSE\n else\n status = TRUE\n MsgBox.Error(\"The minimum watershed size must be a number greater than 0\",\"Watershed\")\n end\nend \n\n' create stream net\nr = (g < minSize.AsNumber.AsGrid).SetNull(1.AsGrid)\n\n'Prompt for flow direction theme. Modified 10/4 zye\nTheThms=av.run(\"hydro.GetThms\",{TheView,false,GTheme})\nTheFdirThm=msgbox.ChoiceAsString(TheThms,\"Select the flow direction grid theme\",Script.The.GetName)\nif(TheFdirThm=nil)then\n exit\nend\nTheFdirGrd=TheFdirThm.GetGrid\n\n\n' get flow dir from extension preferences\n'hydroE xt = Extension.Find(\"Hydrologic Modeling\")\n'if (hydroExt = NIL) then\n' MsgBox.Error(\"Cannot find extension!\",\"Watershed\")\n' return NIL\n'end\n\n'flowDirGThemeName = hydroExt.GetPreferences.Get(\"Flow Direction Property\")\n'theFlowDirGTheme = theView.FindTheme(flowDirGThemeName)\n'\n'theFlowDirGTheme = theView.FindTheme(\"Flow Direction\")\n\n' create watersheds\nr2 = r.StreamLink(TheFdirGrd)\nr3 = TheFdirGrd.Watershed(r2)\n\n' rename data set\naFN = av.GetProject.GetWorkDir.MakeTmp(\"wat\", \"\")\nr3.Rename(aFN)\n\n' check if o utput is ok\nif (r3.HasError) then return NIL end\n\n' create a theme \ngthm = GTheme.Make(r3) \n\n' set name of theme\ngthm.SetName(\"Watersheds\")\n\n' add theme to the specifiedView\ntheView.AddTheme(gthm)\n" ) (Script.142 Name: "Hydro.Install" SourceCode: "' Hydro.Install script\n\n' only install user interface components if a project is open\nif (av.GetProject = NIL) then\n return NIL\nend\n\n' only install user interface componets if they have never been loaded\n' into the project\nif (self.GetPreferences.Get(\"Loaded\") = TRUE) then\n return NIL\nend\n\n' write out version number of extension into preference dictionary\nif (self.GetPreferences.Get(\"Version\") = NIL) then\n self.GetPreferences.Add(\"Version\",self.GetExtVersion)\nend\n\n' install interface components into a Do cGUI named \"View\". If a DocGUI named\n' \"View\" does not exist prompt the user with a list of all DocGUI's of \n' type View and install interface components to all DocGUI selected.\ntheDocGUI = av.GetProject.FindGUI(\"View\")\nif (theDocGUI = NIL) then\n listOfViewDocGUIs = av.GetProject.FindGUIsFor(View)\n installListOfViewDocGUIs = MsgBox.MultiList(listOfViewDocGUIs,\"Choose one or more view document types to add the Hydrologic Modeling interface components to : \",\"Extension Loading\")\nelse\n installListOfViewDocG UIs = {theDocGUI}\nend\nif ((installListOfViewDocGUIs = NIL) or (installListOfViewDocGUIs.Count < 1)) then\n MsgBox.Error(\"Cannot load the interface component of the Hydrologic Modeling extension.\",\"Extension Failure\")\n return NIL\nend\n\nfor each viewDocGUI in installListOfViewDocGUIs\n\n ' Clone widgets to add to project\n extWidgetList = self.Get(0)\n widgetList = extWidgetList.DeepClone\n \n ' place \"Hydro\" menu\n viewMenuBar = viewDocGUI.GetMenuBar\n surfaceMenu = viewMenuBar.FindByLabel(\"Surface\")\n hydroM enu = widgetList.Get(0)\n if (surfaceMenu = NIL) then\n viewMenuBar.Add(hydroMenu,viewMenuBar.GetControls.Count - 1)\n else\n viewMenuBar.Add(hydroMenu,viewMenuBar.GetControls.Find(surfaceMenu))\n end\n \n ' write out \"Loaded\" into the preference dictionary\n self.GetPreferences.Add(\"Loaded\",TRUE)\n viewDocGUI.SetModified(TRUE)\n \nend" ) (Script.143 Name: "Hydro.Uninstall" SourceCode: "' Hydro.Uninstall script\n\n' uninstall user interface components if extension is unloaded, not if \n' project is closed\nif (av.GetProject = NIL) then\n return NIL\nend\nif (av.GetProject.IsClosing) then\n return NIL\nend\n\n' get list of all DocGUI's of type View\nlistOfViewDocGUIs = av.GetProject.FindGUIsFor(View)\n\n' uninstall from all DocGUI's of type View\nfor each viewDocGUI in listOfViewDocGUIs\n ' uninstall tools\n viewToolBar = viewDocGUI.GetToolBar\n t = viewToolBar.FindByName(\"Hydro\")\n while (t <> NIL)\n viewToolBar.Remove(t)\n t = viewToolBar.FindByName(\"Hydro\")\n end\n \n ' uninstall Hydro menu\n viewMenuBar = viewDocGUI.GetMenuBar\n m = viewMenuBar.FindByName(\"Hydro\")\n while (m <> NIL)\n viewMenuBar.Remove(m)\n m = viewMenuBar.FindByName(\"Hydro\")\n end\n \n ' uninstall any other choice on a menu\n for each aMenu in viewMenuBar.GetControls.Clone\n c = aMenu.FindByName(\"Hydro\")\n while (c <> NIL)\n aMenu.Remove(c)\n c = aMenu.FindByName(\"Hydro\")\n end\n if (aMenu.GetControls.Count = 0) then\n viewMenuBar.Remove(aMenu)\n end\n end\n \n ' let project know that the viewDocGUI has been modified\n viewDocGUI.SetModified(TRUE)\nend" )