'=============================================== ' Written by Terry Reese for the NWIUG 2001. Terry Reese is a ' cataloger at Oregon State University. The script is being provided ' free and without warrenty. Users may modify the script and ' re-distribute it, so long as credit is given when due. ' Contact: Terry Reese can be contact at: terry.reese@orst.edu ' ================================================ Const ForReading=1 Const ForWriting=2 Const ForAppend=8 Const TMP_DEST1 = "tmp_break1.txt" Const TMP_DEST2 = "tmp_break2.txt" Const BAD_FILE = "badfile.txt" Dim obj_MARC Dim fso Dim myfile(2) Dim str_Source Dim str_Dest Dim glb_Count Dim tmp_ret '================================================== 'Set our Global Objects '================================================== Set obj_MARC=CreateObject("Marc21.MarcEngine") Set fso=CreateObject("scripting.filesystemobject") str_Source=InputBox("Enter source file") if Len(Trim(str_Source))=0 then MsgBox "A source file must be defined...Quitting" Wscript.quit end if str_Dest=InputBox("Enter destination path") if Len(Trim(str_Dest))=0 then MsgBox "A destination file must be defined...Quitting" Wscript.Quit end if glb_Count=BreakFile() tmp_ret=CorrectFiles() tmp_ret=obj_Marc.MMaker(TMP_DEST2, str_Dest) fso.DeleteFile (TMP_DEST1) fso.DeleteFile (TMP_DEST2) set obj_MARC=nothing msgbox tmp_ret & " records were processed" wscript.quit Function BreakFile() Dim ret_val if fso.fileExists(TMP_DEST1)=True then fso.DeleteFile (TMP_DEST1) end if ret_val=obj_MARC.MarcFile(str_Source, TMP_DEST1) if ret_val=0 then 'We didn't processing any files msgbox "No records were processed. Make sure your file is in proper MARC and try again.", vbokonly, "Error" Wscript.quit else msgbox ret_Val & " records have been pre-processed." & vbcrlf & _ "Script will now add 229 fields to records.", vbokonly, "Processed" end if BreakFile=ret_val End Function Function CorrectFiles() Dim str_Data Dim str_001 Dim str_229 Dim str_949 Dim Marc_String Dim bool_Print_Error Dim bool_Cancel Dim bool_130 Dim bool_240 Dim bool_245 Dim tmp_string Dim tmp_090 Dim tmp_050 Set myfile(0)=fso.OpenTextfile(TMP_DEST1, ForReading) Set myfile(1)=fso.OpenTextfile(TMP_DEST2, ForWriting, TRUE) Set myfile(2)=fso.OpenTextFile(BAD_FILE, ForWriting, TRUE) '=================================================================== 'A couple things to remember: ' 1) Innopac does not re-load records that contain ' the 900 field information, so we have to ' remove it during our processing. ' 2) We must repair the 001 if present, since III exports ' it without the initial 3 characters, but will not ' import a record without them. ' 3) We are going to copy the fields into a 229 if a 222 ' does not exist in the following order: ' a) 130 ' b) 240 ' c) 245 ' 4) Because all Call number fields are duplicated when ' reloaded into III, we must remove one. I have ' set it up to just remove the 090 if they are exactly ' identical ' 5) Fields to be aware of. III's Read/Write MARC records ' utilty will add terminal puntuation to fields, 1xx-899 ' whether they need it or not. Because there are certain ' fields where this is not desireable, I have added ' these fields to the filter list. Currently, the filter ' list includes: ' a) 310 ' b) 321 ' c) 440 ' d) 76x-78x '================================================================== Do while not myfile(0).AtEndOfStream str_Data=myfile(0).ReadLine if Len(Trim(str_Data))=0 then if bool_Print_Error=false then '===================================== 'if it is equal to zero, then we print 'the current MARC string to the file. '===================================== Marc_String=Marc_String & str_229 & vbcrlf myfile(1).write Marc_String & vbcrlf bool_130=false bool_240=false bool_245=false str_229="" Marc_String="" tmp_090="" tmp_050="" else Marc_String=Marc_String & str_229 & vbcrlf myfile(1).write Marc_String & vbcrlf bool_130 = false bool_240=false bool_245=false str_229="" Marc_string="" tmp_090="" tmp_050="" bool_Print_Error=false end if elseif Left(str_Data, 4)="=001" then if isnumeric(Mid(str_data, instr(str_Data, "=001 ") + Len("=001 "), 3)) then tmp_string="ocm" & Mid(str_Data, Instr(str_Data, "=001 ") + Len("=001 ")) Marc_String=Marc_String & "=001 " & tmp_string & vbcrlf else bool_Print_Error=true Marc_String=Marc_String & str_Data & vbcrlf end if elseif Left(str_Data, 4)="=050" then if Len(Trim(tmp_050))=0 then tmp_050=str_Data Marc_String=Marc_String & str_Data & vbcrlf elseif tmp_050<>str_Data then Marc_String=Marc_String & str_Data & vbcrlf end if elseif Left(str_Data, 4)="=090" then if Len(Trim(tmp_090))=0 then tmp_090=str_Data Marc_String=Marc_String & str_Data & vbcrlf elseif tmp_090<>str_Data then Marc_String=Marc_String & str_Data & vbcrlf end if elseif Left(str_Data, 4)="=130" then bool_130=TRUE str_229=str_Data tmp_string=Mid(str_Data, 7,1) Marc_String=Marc_String & str_Data & vbcrlf str_229="=229 \" & tmp_string & Mid(str_Data, Instr(str_Data, "$")) elseif Left(str_Data,4)="=240" then if bool_130<>TRUE then bool_240=TRUE str_229="=229 \" & Mid(str_Data, 8) End If Marc_String=Marc_String & str_Data & vbcrlf elseif Left(str_Data, 4)="=245" then if bool_130<>TRUE and bool_240<>TRUE then bool_245=TRUE str_229="=229 \" & Mid(str_Data, 8) end if Marc_String=Marc_String & str_Data & vbcrlf elseif Left(str_Data, 4)="=222" then bool_cancel=TRUE elseif Left(str_Data, 4)="=229" then bool_cancel=TRUE elseif Left(str_Data, 4)="=310" then if Right(Trim(str_Data), 1)="." then str_Data=Mid(Trim(str_Data), 1, Len(Trim(str_Data)) -1) Marc_String=Marc_String & str_Data & vbcrlf else Marc_String=Marc_String & str_Data & vbcrlf end if elseif Left(str_Data, 4)="=321" then if Right(Trim(str_Data), 1)="." then str_Data=Mid(Trim(str_Data), 1, Len(Trim(str_Data)) -1) Marc_String=Marc_String & str_Data & vbcrlf else Marc_String=Marc_String & str_Data & vbcrlf end if elseif Left(str_Data, 4)="=440" then if Right(Trim(str_Data), 1)="." then str_Data=Mid(Trim(str_Data), 1, Len(Trim(str_Data)) -1) Marc_String=Marc_String & str_Data & vbcrlf else Marc_String=Marc_String & str_Data & vbcrlf end if elseif Left(str_Data, 3)="=76" or Left(str_Data, 3) = "=77" or Left(str_Data, 3) = "=78" then if Right(Trim(str_Data), 1)="." then str_Data=Mid(Trim(str_Data), 1, Len(Trim(str_Data)) -1) Marc_String=Marc_String & str_Data & vbcrlf else Marc_String=Marc_String & str_Data & vbcrlf end if elseif Left(str_Data, 4)="=907" then tmp_string=Mid(str_Data, Instr(str_Data, "$a.b") + len("$a."), 9) Marc_String=Marc_String & "=949 \\$a*recs=b;ov=." & tmp_string & ";" & vbcrlf elseif Left(str_Data, 4) = "=935" then Marc_String=Marc_String & str_Data & vbcrlf elseif Left(str_Data, 4) = "=937" then Marc_String=Marc_String & str_Data & vbcrlf elseif Left(str_Data, 2)="=9" then '**************************************************** 'These lines are not necessary during the reloading 'process, so we will just remove them. '(Note: These fields primarily contain item data ' which we do not want to change.) '**************************************************** str_Data="" else Marc_String=Marc_String & str_Data & vbcrlf end if Loop for x=0 to Ubound(myfile) myfile(x).close Next Msgbox "229 fields have been added to " & glb_Count & " records." & vbcrlf & _ "Re-making MARC file...Please wait", vbokonly, "Processing...." End Function