'MacroName:Level3 'MacroDescription:fix level 3 records 'written by John Lavalie, Sept. 20, 2007 option explicit '-------------------- function replace(strString as string, strOld as string, strNew as string) as string dim pos as integer pos = instr(strString, strOld) do while pos > 0 strString = left(strString, pos - 1) & strNew & mid(strString, pos + len(strOld)) pos = instr(strString, strOld) loop replace = strString end function '------------------- Sub Main Dim CS As Object Set CS = CreateObject("Connex.Client") dim tag$, x%, found, pos%, previousPos%, AuthorMainEntry, dtst$ CS.SetFixedField "Desc", "i" 'move 720s x% = 1: found = FALSE found = CS.GetField("720", 1, tag$) AuthorMainEntry = found do while found CS.DeleteField "720", 1 if right(tag$, 1) <> "." and instr(tag$, chr(223)) = 0 then tag$ = tag$ & "." if x% = 1 then tag$ = "1001 " & mid(tag$, 6) CS.SetField 1, tag$ else tag$ = "7001 " & mid(tag$, 6) CS.SetFieldLine x% + 100, tag$ end if x% = x% + 1 found = CS.GetField("720", 1, tag$) loop 'fix indicator, add period at end of title CS.GetField "245", 1, tag$ tag$ = trim(tag$) if AuthorMainEntry then tag$ = "2451" & mid(tag$, 5) if right(tag$, 1) <> "." then tag$ = tag$ & "." 'insert colon before subB pos% = instr(tag$, chr(223) & "b") if pos% > 0 then if mid$(tag$, pos% - 2, 1) <> ":" then tag$ = left(tag$, pos% - 2) & " : " & mid(tag$, pos%) end if end if 'make title lowercase 'pos% = instr(tag$, " ") 'do until pos% = 0 ' tag$ = left(tag$, pos%) & lcase(mid(tag$, pos% + 1, 1)) & mid(tag$, pos% + 2) ' previousPos% = pos% + 1 ' pos% = instr(previousPos%, tag$, " ") 'loop 'CS.DeleteField "245", 1 CS.SetField 1, tag$ 'fix 260 CS.GetField "260", 1, tag$ pos% = instr(tag$, chr(223) & "c") if pos% > 0 then if mid$(tag$, pos% - 2, 1) <> "," then tag$ = left(tag$, pos% - 2) & ", " & mid(tag$, pos%) CS.DeleteField "260", 1 CS.SetField 1, tag$ end if end if 'add 300 CS.GetField "300", 1, tag$ if len(tag$) < 1 then CS.SetField 1, "300 p. ; " & chr(223) & "c cm." 'fix relator code 'tag$ = "" 'CS.GetField "700", 1, tag$ 'if tag$ > "" then ' tag$ = replace(tag$, " " & chr(223) & "4 ilt", ", " & chr(223) & "e ill.") ' CS.DeleteField "700", 1 ' CS.SetField 99, tag$ 'end if 'fix Dtst=q CS.GetFixedField "DtSt", dtst$ if dtst$ = "q" then CS.SetFixedField "DtSt", "s" CS.Reformat End Sub