'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Script Name: Exam.Open ' Script description: opens a new view, named "Eastern Ontario CSDs", loads ' Eont.shp and Eontcsd.dbf, then joining them, and displaying them in the view window ' The user then selects a field, and whether they want to see records from that field ' below or above the average to the view. ' ' Usage: as button on project menu ' Author: Tom Kralidis ' Created: 19-Oct-1999 ' Changes: ' ' Author Date Changes ' T. Kralidis 19-Oct-1999 Initial Implementation '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' declare global path myPath = "c:/mt/" ' add view presentView = View.Make presentView.SetName("Eastern Ontario CSDs") presentView.GetWin.Open if (nil = presentView) then MsgBox.Error ("Unable to create a new view","") exit end ' add shapefile as theme to view shapeFile = srcName.Make(myPath+"eont.shp") if (shapeFile = nil) then MsgBox.error("Invalid path","") exit end shapeTheme = Theme.Make(shapeFile) presentView.AddTheme(shapeTheme) shapeTheme.SetVisible(true) shapeTheme.SetName("Eastern Ontario CSDs 1991") shapeTheme.SetActive(True) ' add from table (eont.shp theme) myFTab = presentView.GetThemes.Get(0).GetFTab Table.Make(myFTab).GetWin.Open ' add to table (eontcsd.dbf) dbf = (myPath+"eontcsd.dbf").AsFileName theVTab = VTab.Make(dbf, false, false) newTable = Table.Make(theVTab) av.GetProject.AddDoc(newTable) newTable.SetName("eontcsd.dbf") ' get theme records from join field theTheme = presentView.GetThemes.Get(0) theVTab = theTheme.GetFtab theJoinField = theVtab.FindField("Prcdcsd") ' get attribute table records from join field attVTab = newTable.GetVTab attJoinField = attVTab.FindField ("Prcdcsd") ' join tables theVTab.Join (theJoinField, attVTab, attJoinField) theBitmap = myFTab.GetSelection theBitMap.ClearAll ' user selection dialog ' display fields from joined table valFTab = presentView.GetThemes.Get(0).GetFTab myFieldList = valFTab.GetFields myField = MsgBox.ListAsString(myFieldList,"Field Selection","Choose Numeric Field") ' record manipulation from chosen field ' calculate average valSum = 0 valCount = 0 valList = List.Make For each record in valFTab myVal= myFTab.ReturnValue(myField,record) valList.Add(myVal) valSum = valSum + myVal valCount = valCount + 1 end valAverage = valSum / valCount ' setup second (below or above average) window ' giving user choice of above or below the average calculated aboveBelowList = List.Make aboveMean = "Above Mean" belowMean = "Below Mean" aboveBelowList.Add(aboveMean) aboveBelowList.Add(belowMean) myValue = MsgBox.ListAsString(aboveBelowList,"Above or Below Mean?","Choose Value") ' determine user entered choice if (myValue = aboveMean) then myOperator = ">" else myOperator = "<" end ' run query and update display theQuery = "[" + myField.AsString + "]" + myOperator + valAverage.AsString myFTab.Query(theQuery,theBitmap,#VTAB_SELTYPE_NEW) myFTab.UpdateSelection ' display validation message box of user entered-field and average calculated MsgBox.Info(" Field chosen:" ++ myField.AsString ++ NL ++"Mean: " ++ valAverage.AsString,"Output")