'MacroName:UCSD_UbermacroBATCH1902_OnlineOnly!General ' 'MIT License ' 'Copyright (c) 2019 UC San Diego Library ' 'Permission is hereby granted, free of charge, to any person obtaining a copy 'of this software and associated documentation files (the "Software"), to deal 'in the Software without restriction, including without limitation the rights 'to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 'copies of the Software, and to permit persons to whom the Software is 'furnished to do so, subject to the following conditions: ' 'The above copyright notice and this permission notice shall be included in all 'copies or substantial portions of the Software. ' 'THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 'IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 'FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 'AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 'LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 'OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 'SOFTWARE. ' ' 'MacroDescription: This February 2019 version of the Music & Media Uber Macro is a 'simplified, batch-cataloging-dedicated version of more complex macros used in 'general cataloging by the Music & Media Metadata unit of the UC San Diego Metadata 'Services program. 'This macro will start at the beginning of a save file and perform the following 'operations on each record in the file: ' ' 1. Apply the Control All macro command, to control all controllable headings in 'a record. As with manually applying this command, access points for persons 'that lack dates or qualifiers will not be controlled, nor will any headings for 'which there is not match in an authority file. ' 2. Supply RDA relationship designator equivalents for 46 MARC relator codes. If 'there are multiple $4's the $e designators will be supplied in WEMI order and 'alphabetized. It may be necessary to do further work to supply more granular terms 'if the RDA term is not as specific as desired (e.g., "performer"). ' 3. Save the record and move on to the next record, until the end of file is ' reached. Option explicit Declare Sub AddRelationshipDesignator() Dim CS As Object '********************************************** Sub Main On Error GoTo EndMacro Dim Looper as integer Dim Something as string Looper=1 Set CS = CreateObject("Connex.Client") 'Activate this next line if you're dealing with really large files that you want to break into chunks; otherwise process the entire file with the active line. 'Do While Looper<4001 and CS.GetListItem (Looper) = TRUE Do While CS.GetListItem (Looper) = TRUE CS.GetListItem Looper Call AddRelationshipDesignator() If CS.IsOnline <> True Then CS.LogOn "","","" CS.ControlHeadingsAll CS.CloseRecord TRUE Looper=Looper+1 Loop EndMacro: End Sub '********************************************** Sub AddRelationshipDesignator() Set CS = CreateObject("Connex.Client") Dim CursorRowLocation as integer Dim FieldContents as string Dim Replacement as string Dim FieldCounter as integer Dim i as integer Dim j as integer Dim position as integer Dim FieldsToSearchFor(5) as string FieldsToSearchFor(0) = "100" FieldsToSearchFor(1) = "110" FieldsToSearchFor(2) = "111" FieldsToSearchFor(3) = "700" FieldsToSearchFor(4) = "710" FieldsToSearchFor(5) = "711" Dim CodesToTransform(45,1) as string CodesToTransform (0,0) = "aut" CodesToTransform (0,1) = "author" CodesToTransform (1,0) = "cmp" CodesToTransform (1,1) = "composer" CodesToTransform (2,0) = "drt" CodesToTransform (2,1) = "director" CodesToTransform (3,0) = "cng" CodesToTransform (3,1) = "director of photography" CodesToTransform (4,0) = "fmd" CodesToTransform (4,1) = "film director" CodesToTransform (5,0) = "fmp" CodesToTransform (5,1) = "film producer" CodesToTransform (6,0) = "fmk" CodesToTransform (6,1) = "filmmaker" CodesToTransform (7,0) = "ive" CodesToTransform (7,1) = "interviewee" CodesToTransform (8,0) = "ivr" CodesToTransform (8,1) = "interviewer" CodesToTransform (9,0) = "lbt" CodesToTransform (9,1) = "librettist" CodesToTransform (10,0) = "lyr" CodesToTransform (10,1) = "lyricist" CodesToTransform (11,0) = "pro" CodesToTransform (11,1) = "producer" CodesToTransform (12,0) = "prn" CodesToTransform (12,1) = "production company" CodesToTransform (13,0) = "aus" CodesToTransform (13,1) = "screenwriter" CodesToTransform (14,0) = "tld" CodesToTransform (14,1) = "television director" CodesToTransform (15,0) = "tlp" CodesToTransform (15,1) = "television producer" CodesToTransform (16,0) = "act" CodesToTransform (16,1) = "actor" CodesToTransform (17,0) = "anm" CodesToTransform (17,1) = "animator" CodesToTransform (18,0) = "arr" CodesToTransform (18,1) = "arranger of music" CodesToTransform (19,0) = "ard" CodesToTransform (19,1) = "art director" CodesToTransform (20,0) = "cmm" CodesToTransform (20,1) = "commentator" CodesToTransform (21,0) = "cnd" CodesToTransform (21,1) = "conductor" CodesToTransform (22,0) = "cst" CodesToTransform (22,1) = "costume designer" CodesToTransform (23,0) = "dnc" CodesToTransform (23,1) = "dancer" CodesToTransform (24,0) = "edt" CodesToTransform (24,1) = "editor" CodesToTransform (25,0) = "edm" CodesToTransform (25,1) = "editor of moving image work" CodesToTransform (26,0) = "hst" CodesToTransform (26,1) = "host" CodesToTransform (27,0) = "itr" CodesToTransform (27,1) = "instrumentalist" CodesToTransform (28,0) = "mod" CodesToTransform (28,1) = "moderator" CodesToTransform (29,0) = "nrt" CodesToTransform (29,1) = "narrator" CodesToTransform (30,0) = "osp" CodesToTransform (30,1) = "on-screen presenter" CodesToTransform (31,0) = "pan" CodesToTransform (31,1) = "panelist" CodesToTransform (32,0) = "prf" CodesToTransform (32,1) = "performer" CodesToTransform (33,0) = "prn" CodesToTransform (33,1) = "production company" CodesToTransform (34,0) = "pre" CodesToTransform (34,1) = "presenter" CodesToTransform (35,0) = "prs" CodesToTransform (35,1) = "production designer" CodesToTransform (36,0) = "ppt" CodesToTransform (36,1) = "puppeteer" CodesToTransform (37,0) = "rce" CodesToTransform (37,1) = "recording engineer" CodesToTransform (38,0) = "rcd" CodesToTransform (38,1) = "recordist" CodesToTransform (39,0) = "voc" CodesToTransform (39,1) = "singer" CodesToTransform (40,0) = "sng" CodesToTransform (40,1) = "singer" CodesToTransform (41,0) = "sds" CodesToTransform (41,1) = "sound designer" CodesToTransform (42,0) = "spk" CodesToTransform (42,1) = "speaker" CodesToTransform (43,0) = "sgd" CodesToTransform (43,1) = "stage director" CodesToTransform (44,0) = "vac" CodesToTransform (44,1) = "voice actor" CodesToTransform (45,0) = "wac" CodesToTransform (45,1) = "writer of added commentary" CS.CursorRow = 1 CS.CursorColumn = 1 For i = 0 to 5 FieldCounter = 1 Do while CS.GetField(FieldsToSearchFor(i),FieldCounter,FieldContents) CS.FindText Mid(FieldContents,6,Len(FieldContents)),FALSE CursorRowLocation = CS.CursorRow If InStr(FieldContents, Chr(223) & "4") then For j = 0 to 45 If (InStr(FieldContents, chr(223) & "4 " & CodesToTransform (j,0)) <> FALSE) and (InStr(FieldContents, chr(223) & "e " & CodesToTransform (j,1)) = FALSE) Then If InStr(FieldContents, ". " & chr(223) & "4 ") Then position = InStr(FieldContents, ". " & chr(223) & "4 ") Replacement = Left(FieldContents,(position-1)) & ", " & chr(223) & "e " & CodesToTransform (j,1) & "." & Right(FieldContents,(Len(FieldContents)-position)) If CS.IsHeadingControlled(CursorRowLocation) = TRUE then CS.UncontrolHeading CS.SetFieldLine CursorRowLocation, Replacement FieldContents=Replacement End If If InStr(FieldContents, "- " & chr(223) & "4 ") Then position = InStr(FieldContents, "- " & chr(223) & "4 ") Replacement = Left(FieldContents,(position-1)) & "- " & chr(223) & "e " & CodesToTransform (j,1) & "." & Right(FieldContents,(Len(FieldContents)-position)) If CS.IsHeadingControlled(CursorRowLocation) = TRUE then CS.UncontrolHeading CS.SetFieldLine CursorRowLocation, Replacement FieldContents=Replacement End If If InStr(FieldContents, ") " & chr(223) & "4 ") Then position = InStr(FieldContents, ") " & chr(223) & "4 ") Replacement = Left(FieldContents,(position-1)) & "), " & chr(223) & "e " & CodesToTransform (j,1) & "." & Right(FieldContents,(Len(FieldContents)-position)) If CS.IsHeadingControlled(CursorRowLocation) = TRUE then CS.UncontrolHeading CS.SetFieldLine CursorRowLocation, Replacement FieldContents=Replacement End If End If Next j If InStr(FieldContents, chr(223) & "4 voc") then CS.ReplaceText chr(223) & "4 voc",chr(223) & "4 sng",False End If If ((Mid(FieldContents,1,3) = "700") or (Mid(FieldContents,1,3) = "730")) and (Mid(FieldContents,5,1) = "2") and (Mid(FieldContents,9,12) <> "Container of") Then CS.GetFieldLine CursorRowLocation,FieldContents If CS.IsHeadingControlled(CursorRowLocation) = TRUE then CS.UncontrolHeading CS.CursorRow = CursorRowLocation CS.CursorColumn = 6 If (InStr(FieldContents, chr(223) & "l") <> FALSE) or (InStr(FieldContents, chr(223) & "o") <> FALSE) or (InStr(FieldContents, chr(223) & "s") <> FALSE) then If (InStr(FieldContents, "Contains (expression):") <> FALSE) then If (CS.FindText("Contains (expression):",False)) then CS.CursorColumn = 6 CS.ReplaceText "Contains (expression):","Container of (expression):",False End If Else Replacement = Left(FieldContents,5) & chr(223) & "i Container of (expression): " & chr(223) & "a " & Right(FieldContents,(Len(FieldContents)-5)) If CS.IsHeadingControlled(CursorRowLocation) = TRUE then CS.UncontrolHeading CS.SetFieldLine CursorRowLocation, Replacement End If Else If (InStr(FieldContents, "Contains (work):") <> FALSE) then If (CS.FindText("Contains (work):",False)) then CS.CursorColumn = 6 CS.ReplaceText "Contains (work):","Container of (work):",False End If Else Replacement = Left(FieldContents,5) & chr(223) & "i Container of (work): " & chr(223) & "a " & Right(FieldContents,(Len(FieldContents)-5)) If CS.IsHeadingControlled(CursorRowLocation) = TRUE then CS.UncontrolHeading CS.SetFieldLine CursorRowLocation, Replacement End If End If End if FieldCounter = FieldCounter + 1 Loop Next i End Sub