ARCVIEW 3.x LEGEND TEXT ITEM SCRIPT Here's a script that allows you to to pick a descriptive field to populate the "Label" entries of a legend. Works for joined (lookup table) items too! If a one-to-many relationship exists between the value field and the label field, the first value encountered will be used. ======================================================================= INSTALLING THE MENU ITEM IN THE DEFAULT PROJECT 1) Begin a NEW ArcView 3.x session. 2) Create a new script by double-clicking on the "Scripts" icon 3) Use "Properties..." under the "Script" menu to rename Script1 to View.LegendTextItem 4) Paste the following text: '====================================================================== ' View.LegendTextItem theTitle = "Legend Text Item" theView = av.GetActiveDoc theTheme = theView.GetActiveThemes.Get(0) if (theTheme.Is(FTheme).Not) then MsgBox.Error("Active theme is not FTheme",theTitle) return nil end theLegend = theTheme.GetLegend theFTab = theTheme.GetFTab flist = List.Make for each f in theFTab.GetFields if ((f.IsTypeShape.Not) and (f.IsVisible)) then flist.Add(f) end end TextField = MsgBox.Choice(flist,"Select Field:",theTitle) if (TextField = nil) then return nil end num_c = theLegend.GetNumClasses vfname = theLegend.ReturnFieldNames.Get(0) ValueField = theFTab.FindField(vfname) '**** create summary table for value and text fields t_name = FileName.GetTmpDir.MakeTmp("sum","dbf") t = theFTab.Summarize(t_name,dBASE,ValueField,{TextField},{#VTAB_SUMMARY_FIRST}) vf = t.GetFields.Get(0) vf_name = vf.GetName tf = t.GetFields.Get(2) bm = t.GetSelection '**** update legend for each i in 0..(num_c - 1) clist = theLegend.ReturnClassInfo(i) val_s = clist.Get(1) if (vf.IsTypeString) then val_s = val_s.Quote end '**** perform query for value q = "[" + vf_name + "] =" ++ val_s t.Query(q,bm,#VTAB_SELTYPE_NEW) '**** retrieve text item value and insert into legent r = bm.GetNextSet(-1) if (r = -1) then continue end theText = t.ReturnValue(tf,r).AsString clist.Set(0,theText) theLegend.SetClassInfo(i,clist) end '**** clean up bm = nil vf = nil tf = nil t = nil av.PurgeObjects File.Delete(t_name) theView.InvalidateTOC(theTheme) av.GetProject.SetModified(true) return nil '====================================================================== 5) Compile and close the script 6) Double-click the tool bar, choose "View" and "Menus", and create a new item under the "Theme" menu 7) Double-click "Click" and select View.LegendTextItem 8) Double-click "Update" and select View.ActiveThemesUpdate 9) Double-click "Label" and enter: Legend Text Item 10) Double-click "Help" and enter: Use field in active theme to populate legend description 11) Click the "Make Default Button" and then close the Customize dialog box 12) EXIT ArcView (do not save changes to "Untitled") and you're done! ======================================================================= INSTALLING THE BUTTON IN A SPECIFIC PROJECT 1) Open the desired project and follow steps 2-10 above 2) Close the "Customizer" and save the project This control (among others) may also be installed by loading the Stuff! extension. ======================================================================= USING THE "THEME|LEGEND TEXT ITEM" MENU ITEM One theme should be active, and must be an FTheme. After clicking the menu entry, a dialog will appear listing the available items. If a one-to-many relationship exists between the legend's value field and the label field, the first value encountered will be used. ======================================================================= Mark Cederholm plp@pierssen.com http://www.pierssen.com/PC/arcinfo.htm http://www.pierssen.com/arcview/arcview.htm