'********************************************************************
'Script Name: drgtable.open
'
'Author: Sean P Fields
' U.S. Fish and Wildlife Service
' Division of Refuge Planning
' Lakewood, Colorado
'
' Modified by
' Dan Martin, 303 236-0105
' BLM WO-ST-D
' Lakewood, Colorado
'
'Description: Allows the user to choose a drg quad map
' from a pull down menu. The script must
' be attached to a button in a view. The script
' uses a dbf file to access the quad names
' and file locations. Modified for BLM Canyon of the Ancients, Colorado
'
'Original Coding: 10/30/99
'Modified: 08/15/01, 04/23/02
'
'********************************************************************


'GET THE DRG TABLE AND MAKE A VTAB
theTable = "C:\GIS\Colorado\DRG\quads1.dbf".AsFileName
theVTab = Vtab.Make(theTable, false, false)

'GET THE FIELDS AND ASSOCIATED VALUE LISTS
theNameField = theVTab.FindField("Quadname")
theFileField = theVTab.FindField("Quadpath")

theList = {}
for each rec in theVTab
theName = theVTab.ReturnValueString(theNameField,rec)
theList.Add(theName)
end

'GET THE VIEW
theView = av.GetActiveDoc

'PROMPT THE USER FOR THE DESIRED QUAD
theQuad = Msgbox.ChoiceAsString(theList, "Choose a 7.5 K Quad Map to Display:","Topographic Quadrangle Maps")

if (theQuad = Nil) then
return nil
end

'SET THE DRG FILENAME
theBitmap = theVTab.GetSelection
theQuery = "[QuadName] = "+theQuad.Quote
theVtab.Query(theQuery, theBitmap,#VTAB_SELTYPE_NEW)


for each rec in theBitmap
theFile = theVtab.ReturnValueString(theFileField,rec)end

'ADD THE DRG TO THE VIEW
theSrcName = SrcName.Make(theFile)
if (theSrcName <> nil) then
theTheme = Theme.Make(theSrcName)
theView.AddTheme(theTheme)
theTheme.SetActive(true)
theTheme.SetVisible(true)
theView.GetDisplay.SetExtent(theTheme.ReturnExtent)
else
msgbox.error("The Quad does not exist","")
return nil
end