'MacroName:246& 'MacroDescription:Adds 246 for title with ampersand 'written by John Lavalie, Sept. 2006 option explicit global hdgChanged '-------------------- 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) hdgChanged = TRUE loop replace = strString end function '------------------- Sub Main Dim CS As Object Set CS = CreateObject("Connex.Client") dim bool, tag245$, tag$, filing%, subfield%, x%, p%, b% bool = CS.GetField ("245", 1, tag245$) tag$ = tag245$ filing% = val(mid(tag$, 5)) tag$ = mid(tag$, 6) subfield% = instr(tag$, chr(223)) if subfield% > 0 then tag$ = left(tag$, subfield% - 2) tag$ = trim(mid(tag$, filing% + 1)) tag$ = trim(ucase(left(tag$, 1)) & mid(tag$, 2)) if right(tag$, 1) = "/" then tag$ = trim(left(tag$, len(tag$) - 1)) if right(tag$, 1) = ":" then tag$ = trim(left(tag$, len(tag$) - 1)) tag$ = replace(tag$, "&", "and") tag$ = replace(tag$, "+", "and") 'embedded capitals x% = 1 do while x% < len(tag$) x% = x% + 1 if mid(tag$, x%, 2) like "[a-z][A-Z]" then tag$ = left(tag$, x%) & " " & lcase(mid(tag$, x% + 1, 1)) & mid(tag$, x% + 2) end if loop if hdgChanged then tag$ = "2463 " & tag$ CS.AddField 1, tag$ end if 'part titles tag$ = mid(tag245$, 6) p% = instr(tag$, chr(223) & "p") if p% > 0 then x% = instr(p% + 2, tag$, chr(223)) if x% = 0 then x% = len(tag$) tag$ = trim(mid(tag$, p% + 2, x% - 2 - p%)) if right(tag$, 1) = "/" then tag$ = trim(left(tag$, len(tag$) - 1)) tag$ = "24630" & tag$ CS.AddField 1, tag$ end if 'subtitles tag$ = mid(tag245$, 6) b% = instr(tag$, chr(223) & "b") if b% > 0 then x% = instr(b% + 2, tag$, chr(223)) if x% = 0 then x% = len(tag$) tag$ = trim(mid(tag$, b% + 2, x% - 2 - b%)) if right(tag$, 1) = "/" then tag$ = trim(left(tag$, len(tag$) - 1)) tag$ = ucase(left(tag$, 1)) & mid(tag$, 2) if instr(tag245$, "= " & chr(223) & "b") then tag$ = "24631" & tag$ else tag$ = "24630" & tag$ end if CS.AddField 1, tag$ end if CS.RunMacro "DPK!idiot" end sub