'MacroName:508-511to700 'MacroDescription:Copy 508/511 names to 700s 'Macro created by: Joel Hahn, Niles Public Library District 'Last Updated: 23 May 2003 '-------------- 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") 'CS.GetActiveRecord CS.GetFixedField "Tech", tech$ Begin Dialog newdlg 76, 90 OptionGroup .Choice OptionButton 18, 10, 40, 12, "508 to 700" OptionButton 18, 27, 40, 12, "511 to 700" OptionButton 18, 45, 44, 12, "Both to 700" OkButton 7, 62, 30, 14 CancelButton 40, 62, 30, 14 End Dialog Dim Choice as newdlg Choice.Choice = 1 x = Dialog(Choice) If x = 0 Then Goto Done If Choice.Choice <> 1 Then 'User selected either "508 to 700" or "Both to 700" z=1 Do check = CS.GetField("508", z, text$) If check <> FALSE Then count = 1 Do GFcheck = Instr(GFcheck+1,text$,";") If GFcheck > 0 then count = count + 1 Loop While GFcheck > 0 count2 = 1 Do data$ = GetField(text$, count2, ";") If InStr(data$,"by") then pname$ = Trim(GetField(data$, 3, "by")) Else pname$ = Trim(GetField(data$, 2, ",")) End if i = Len(pname$) Do test$ = Mid(pname$,i,1) If test$ = " " Then LastName$ = Right(pname$, Len(pname$)-i) If Right(LastName$,1) = "." Then LastName$ = Left(LastName$, Len(LastName)-1) FirstName$ = Left(pname$, i-1) bool = CS.AddField(999, "7001 " & LastName$ & ", " & FirstName & ".") Exit Do End If i = i - 1 If i = 0 Then bool = CS.AddField(999, "7001 " & pname$ & ".") End If Loop Until i = 0 count2 = count2 + 1 Loop While count2 <= count End if DoNext: z = z + 1 Loop While check <> FALSE End If If Choice.Choice<>0 Then 'User selected either "511 to 700" or "Both to 700" z=1 Do check = CS.GetField("511", z, text$) If check <> FALSE Then count = 1 Do GFcheck = Instr(GFcheck + 1, text$, ",") If GFcheck > 0 then count = count + 1 Loop While GFcheck > 0 count2 = 1 Do pname$ = Trim(GetField(text$, count2, ",")) 'fuddle begin if instr(pname$, "Narrated by ") then pname$ = " " + ltrim(mid(pname$, 18)) else if instr(pname$, "Read by ") then pname$ = " " + ltrim(mid(pname$, 13)) else if instr(pname$, "Performed by ") then pname$ = " " + ltrim(mid(pname$, 19)) end if end if end if 'fuddle end If count2 = 1 Then pname$ = Right(pname$, Len(pname$)-5) i = Len(pname$) 'add relator codes based on MARC record type CS.GetFixedField "Type", strType If strType = "g" and left(text$, 4) = "5111" Then relator = ", " & chr(223) if tech$ = "a" then relator = relator & "e voice actor." else relator = relator & "e actor." end if else if strType = "i" Then relator = " " & chr(223) & "e narrator." end if end if Do test$ = Mid(pname$,i,1) If test$ = " " Then LastName$ = Right(pname$, Len(pname$)-i) If Right(LastName$,1) = "." Then LastName$ = Left(LastName$, Len(LastName)-1) FirstName$ = Left(pname$, i-1) bool = CS.AddField(999, "7001 " & LastName$ & ", " & FirstName & "" & relator) Exit Do End If i = i - 1 If i = 0 Then bool = CS.AddField(999, "7001 " & pname$ & "." & relator) End If Loop Until i = 0 count2 = count2 + 1 Loop While count2 <= count End If DoNext2: z = z + 1 Loop While check=TRUE End If Done: end sub