' ID_Append.bas ' ' This script appends a prefix and/or suffix to the current value of any ' ID or attribute field of the selected objects. ' ' Mike Blessing, Golden Software, 29-Jul-2004 ' mapviewersupport@goldensoftware.com ' Option Explicit Sub Main Dim mvApp, lyr As Object ' Find MapViewer and create a pointer to the application object Set mvApp = GetObject(,"MapViewer.Application") ' Make sure that at least one object is selected Set lyr = mvApp.ActiveDocument.ActiveLayer If lyr.Selection.Count = 0 Then MsgBox "Appending to IDs requires that" & vbCrLf & "one or more objects be selected first." End End If ' Create and display the dialog to find out which ' ID should be modified and get the strings to use ' for the prefix and/or suffix. Dim ID_List(4) As String ID_List(0) = "PID" ID_List(1) = "SID" ID_List(2) = "Attrib 1" ID_List(3) = "Attrib 2" ID_List(4) = "Hyperlink" Begin Dialog UserDialog 270,119,"Append to IDs" ' %GRID:10,7,1,1 DropListBox 90,7,180,112,ID_List(),.ID1 Text 30,42,60,14,"Prefix",.Text2,2 OKButton 40,91,90,21 CancelButton 150,91,90,21 Text 0,7,80,14,"ID to modify",.Text1,1 TextBox 10,56,110,21,.Prefix TextBox 150,56,110,21,.Suffix Text 180,42,50,14,"Suffix",.Text3,2 End Dialog Dim dlg As UserDialog dlg.ID1 = 0 Dim sts As Integer sts = Dialog(dlg) ' The Cancel button returns 0. ' The OK button returns -1. If sts = 0 Then ' cancel button pressed End End If ' For each selected object, get the current attribute value, ' add the prefix and suffix and store it back. Dim i As Integer Select Case dlg.ID1 Case 0 'PID For i = 1 To lyr.Selection.Count lyr.Selection.Item(i).PIDName = dlg.Prefix & lyr.Selection.Item(i).PIDName & dlg.Suffix Next Case 1 'SID For i = 1 To lyr.Selection.Count lyr.Selection.Item(i).SIDName = dlg.Prefix & lyr.Selection.Item(i).SIDName & dlg.Suffix Next Case 2 'Attrib1 For i = 1 To lyr.Selection.Count lyr.Selection.Item(i).Attrib1 = dlg.Prefix & lyr.Selection.Item(i).Attrib1 & dlg.Suffix Next ' refresh the OM lyr.Shapes.InvertSelection() lyr.Shapes.InvertSelection() Case 3 'Attrib2 For i = 1 To lyr.Selection.Count lyr.Selection.Item(i).Attrib2 = dlg.Prefix & lyr.Selection.Item(i).Attrib2 & dlg.Suffix Next ' refresh the OM lyr.Shapes.InvertSelection() lyr.Shapes.InvertSelection() Case 4 'Hyperlink For i = 1 To lyr.Selection.Count lyr.Selection.Item(i).HyperlinkStr = dlg.Prefix & lyr.Selection.Item(i).HyperlinkStr & dlg.Suffix Next ' refresh the OM lyr.Shapes.InvertSelection() lyr.Shapes.InvertSelection() End Select End Sub