' ID_Concatenate.bas ' ' This script operates on the ID and attribute fields of selected objects. ' It concatenates two fields together and stores the results to the field of choice. ' ' 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 "Concatenating IDs requires that" & vbCrLf & "one or more objects be selected first." End End If ' Create and display the dialog to find out which ' IDs should be concatenated and where the result ' should be stored. 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 300,126,"Concatenate IDs" ' %GRID:10,7,1,1 DropListBox 110,7,180,119,ID_List(),.ID1 DropListBox 110,28,180,119,ID_List(),.ID2 Text 10,63,90,14,"and assign to",.Text2,1 DropListBox 110,63,180,119,ID_List(),.ID3 OKButton 70,98,90,21 CancelButton 180,98,90,21 Text 10,7,90,14,"Concatenate",.Text1,1 Text 70,28,30,14,"with",.Text3,1 End Dialog Dim dlg As UserDialog dlg.ID1 = 0 dlg.ID2 = 0 dlg.ID3 = 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 first attribute, ' concatenate the second, and store in the third. Dim newID As String Dim i As Integer For i = 1 To lyr.Selection.Count Select Case dlg.ID1 Case 0 'PID newID = lyr.Selection.Item(i).PIDName Case 1 'SID newID = lyr.Selection.Item(i).SIDName Case 2 'Attrib1 newID = lyr.Selection.Item(i).Attrib1 Case 3 'Attrib2 newID = lyr.Selection.Item(i).Attrib2 Case 4 'Hyperlink newID = lyr.Selection.Item(i).HyperlinkStr End Select Select Case dlg.ID2 Case 0 'PID newID = newID & lyr.Selection.Item(i).PIDName Case 1 'SID newID = newID & lyr.Selection.Item(i).SIDName Case 2 'Attrib1 newID = newID & lyr.Selection.Item(i).Attrib1 Case 3 'Attrib2 newID = newID & lyr.Selection.Item(i).Attrib2 Case 4 'Hyperlink newID = newID & lyr.Selection.Item(i).HyperlinkStr End Select Select Case dlg.ID3 Case 0 'PID lyr.Selection.Item(i).PIDName = newID Case 1 'SID lyr.Selection.Item(i).SIDName = newID Case 2 'Attrib1 lyr.Selection.Item(i).Attrib1 = newID Case 3 'Attrib2 lyr.Selection.Item(i).Attrib2 = newID Case 4 'Hyperlink lyr.Selection.Item(i).HyperlinkStr = newID End Select Next If dlg.ID3 > 1 Then ' refresh the OM lyr.Shapes.InvertSelection() lyr.Shapes.InvertSelection() End If End Sub