'MacroName:518to033 'Description: Creates a 033 tag based on the 518 tag or a "Durations" note 'by John Lavalie, July 14, 2006 option explicit option compare text option base 1 global strMonth(13) as string '-------------- sub loadMonths strMonth(1) = "Jan." : strMonth(2) = "Feb." : strMonth(3) = "Mar." : strMonth(4) = "Apr." strMonth(5) = "May." : strMonth(6) = "June" : strMonth(7) = "July" : strMonth(8) = "Aug." strMonth(9) = "Sep." : strMonth(10) = "Oct." : strMonth(11) = "Nov." : strMonth(12) = "Dec." end sub '-------------- 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 '--------------- function getMonth(mn$) as string dim x% for x% = 1 to 12 if instr(strMonth(x%), mn$) then mn$ = trim(str(x%)) if len(mn$) = 1 then mn$ = "0" & mn$ end if next getMonth = mn$ end function '--------------- Sub Main Dim CS As Object Set CS = CreateObject("Connex.Client") dim bool, hasMonth dim tag518$, tag033$ dim subA$ dim yr$, mo$ dim x%, y% LoadMonths hasMonth = FALSE subA = " " & chr(223) & "a " bool = CS.GetField ("518", 1, tag518$) bool = FALSE tag518$ = mid(tag518$, 6) 'make all months 4 characters tag518$ = replace(tag518$, "Sept.", "Sep.") tag518$ = replace(tag518$, "May ", "May. ") 'standardize connectors, shorten string tag518$ = replace(tag518$, " and ", "-") tag518$ = replace(tag518$, " & ", "-") tag518$ = replace(tag518$, "Originally ", "") 'does 518 contain a month? for x% = 1 to 12 if instr(tag518$, strMonth(x%)) then hasMonth = TRUE next if not hasMonth then bool = false 'case 2000-2006 for x% = 1 to len(tag518$) - 9 if mid(tag518$, x%, 9) like "####-####" then tag033$ = "03320" & mid(tag518$, x%, 4) & "----" & subA & mid(tag518$, x% + 5, 4) & "----" bool = true end if next if not bool then 'case 2006 for x% = 1 to len(tag518$) - 4 if mid(tag518$, x%, 4) like "####" then tag033$ = "03300" & mid(tag518$, x%, 4) & "----" next end if else 'case Dec. 2005-Jan. 2006 for x% = 1 to len(tag518$) - 19 if mid(tag518$, x%, 19) like "[A-Z][a-z][a-z]. ####-[A-Z][a-z][a-z]. ####" then bool = TRUE tag033$ = "03300" & mid(tag518$, x% + 5, 4) & getMonth(mid(tag518$, x%, 4)) & "--" & subA tag033$ = tag033$ & mid(tag518$, x% + 15, 4) & getMonth(mid(tag518$, x% + 10, 4)) & "--" end if next 'case Mar.-Apr. 2006 if not bool then for x% = 1 to len(tag518$) - 14 if mid(tag518$, x%, 14) like "????-???? ####" then bool = TRUE yr$ = mid(tag518$, x% + 10, 4) tag033$ = "03320" & yr$ & getMonth(mid(tag518$, x%, 4)) & "--" & subA tag033$ = tag033$ & yr$ & getMonth(mid(tag518$, x% + 5, 4)) & "--" end if next end if if not bool then 'case Mar. 2006 for x% = 1 to len(tag518$) - 9 if mid(tag518$, x%, 9) like "[A-Z][a-z][a-z]? ####" then bool = TRUE tag033$ = "03300" & mid(tag518$, x% + 5, 4) & getMonth(mid(tag518$, x%, 4)) & "--" end if next end if if not bool then '518 contains month and day. Add leading zero to date as necessary for x% = 1 to len(tag518$) - 4 if mid(tag518$, x%, 4) like ". #-" then tag518$ = left(tag518$, x% + 1) & "0" & mid(tag518$, x% + 2) next for x% = 1 to len(tag518$) - 3 if mid(tag518$, x%, 3) like "-#," then tag518$ = left(tag518$, x%) & "0" & mid(tag518$, x% + 1) next 'case Mar. 15-18, 2006 for x% = 1 to len(tag518$) - 16 if mid(tag518$, x%, 16) like "???? ##-##, ####" then bool = TRUE yr$ = mid(tag518$, x% + 12, 4) mo$ = getMonth(mid(tag518$, x%, 4)) tag033$ = "03320" & yr$ & mo$ & mid(tag518$, x% + 5, 2) & subA tag033$ = tag033$ & yr$ & mo$ & mid(tag518$, x% + 8, 2) end if next 'case Mar. 5-18, 2006 for x% = 1 to len(tag518$) - 15 if mid(tag518$, x%, 15) like "???? #-##, ####" then bool = TRUE yr$ = mid(tag518$, x% + 11, 4) mo$ = getMonth(mid(tag518$, x%, 4)) tag033$ = "03320" & yr$ & mo$ & "0" & mid(tag518$, x% + 5, 1) & subA tag033$ = tag033$ & yr$ & mo$ & mid(tag518$, x% + 7, 2) end if next if not bool then 'case Mar. 15-Apr. 17, 2006 for x% = 1 to len(tag518$) - 21 if mid(tag518$, x%, 21) like "???? ##-???? ##, ####" then bool = TRUE yr$ = mid(tag518$, x% + 17, 4) mo$ = getMonth(mid(tag518$, x%, 4)) tag033$ = "03320" & yr$ & mo$ & mid(tag518$, x% + 5, 2) & subA mo$ = getMonth(mid(tag518$, x% + 8, 4)) tag033$ = tag033$ & yr$ & mo$ & mid(tag518$, x% + 13, 2) end if next if not bool then 'case Mar. 19-Apr. 8, 2006 for x% = 1 to len(tag518$) if mid(tag518$, x%, 21) like "???? ##-???? #, ####" then bool = TRUE yr$ = mid(tag518$, x% + 17, 4) mo$ = getMonth(mid(tag518$, x%, 4)) tag033$ = "03320" & yr$ & mo$ & mid(tag518$, x% + 5, 2) & subA mo$ = getMonth(mid(tag518$, x% + 8, 4)) tag033$ = tag033$ & yr$ & mo$ & mid(tag518$, x% + 13, 2) end if next end if if not bool then 'case Dec. 28, 2005-Jan. 15, 2006 for x% = 1 to len(tag518$) - 27 if mid(tag518$, x%, 27) like "???? ##, ####-???? ##, ####" then bool = TRUE yr$ = mid(tag518$, x% + 9, 4) mo$ = getMonth(mid(tag518$, x%, 4)) tag033$ = "03320" & yr$ & mo$ & mid(tag518$, x% + 5, 2) & subA yr$ = mid(tag518$, x% + 23, 4) mo$ = getMonth(mid(tag518$, x% + 14, 4)) tag033$ = tag033$ & yr$ & mo$ & mid(tag518$, x% + 19, 2) end if next end if if not bool then 'case Mar. 15, 2006 for x% = 1 to len(tag518$) - 13 if mid(tag518$, x%, 13) like "???? ##, ####" then tag033$ = "03300" & mid(tag518$, x% + 9, 4) & getMonth(mid(tag518$, x%, 4)) & mid(tag518$, x% + 5, 2) end if next end if if not bool then 'case Mar. 1, 2006 for x% = 1 to len(tag518$) - 12 if mid(tag518$, x%, 12) like "???? #, ####" then tag033$ = "03300" & mid(tag518$, x% + 8, 4) & getMonth(mid(tag518$, x%, 4)) & "0" & mid(tag518$, x% + 5, 1) end if next end if end if end if end if 'change 2nd indicator for broadcast if instr(tag518$, "broadcast") or instr(tag518$, "television") or instr(tag518$, "radio") then tag033$ = left(tag033$, 4) & "1" & mid(tag033$, 6) else 'update fixed fields CS.SetFixedField "DtST", "p" CS.SetFixedField ",", mid(tag033$, 6, 4) end if 'add 033 CS.SetField 1, tag033$ CS.Reformat End Sub