HOW TO
Code:
'** ChooseQuery.AddQuery
'** YOU MUST SET THESE VARIABLES!:
ViewName = "View1"
ThemeName = "States.shp"
QueryStr = "( [Pop1990] < 666168 )"
QueryName = "Low Population"
'** Derive objects to use
v = av.GetProject.FindDoc(ViewName)
t = v.FindTheme(ThemeName)
f = t.GetFTab
'** Check to see if the view already has a tag.
'** Presumes its the right kind of tag.
vtag = v.GetObjectTag
if (vtag = nil) then
vtag = Dictionary.Make(1)
elseif (vtag.is(Dictionary)) then
x = vtag.ReturnKeys.Get(0)
if ((vtag.Get(x).Is(List)).not) then
Msgbox.Warning("View already has a different"+
" object tag--cannot continue","")
exit
end
end
'** Execute the query
b = f.GetSelection
r = f.Query(QueryStr,b,#VTAB_SELTYPE_NEW)
if (r.not) then
Msgbox.Error("That query did not work right!","")
exit
end
f.UpdateSelection
'** Set the ObjectTag
vtag.Add(QueryName, {ThemeName, f.GetSelection.Clone})
v.SetObjectTag(vtag)
Code:
'** ChooseQuery.Click
'** Ask user to choose a saved query
v = av.GetActiveDoc
vtag = v.GetObjectTag
lKeys = vtag.ReturnKeys
sq = Msgbox.ChoiceAsString(lKeys,"Choose a query:",
"Saved Queries")
'** Check the result & get parameters
if (sq = nil) then exit end
ThemeName = vtag.Get(sq).Get(0)
selBit = vtag.Get(sq).Get(1)
t = v.FindTheme(ThemeName)
if (t = nil) then
Msgbox.Info("could not find theme: "+ThemeName+
". Cannot continue.","")
exit
end
'** Apply the selected Bitmap
f = t.GetFTab
f.SetSelection(selBit)
f.UpdateSelection
Get help from ArcGIS experts
Download the Esri Support App