'================================================= 'Written by Terry Reese 'Description: III_Fix.vbs -- This script will ' fix a handful of common problems ' caused when export III MARC records ' using the III Read/Write utility. 'How to use: Once you have broken a MARC file that ' was exported from III, open that file ' in the MarcEditor. With the file open ' select III_fix from the Plugin entry ' under File/Plugins 'Questions: terry.reese@orst.edu '================================================= Const ForReading=1 Const ForWriting=2 Const ForAppend=8 Dim obj_MarcEdit Dim fso Dim myfile(1) Dim str_Source Dim str_Dest Dim str_TempFile Dim glb_Count Dim tmp_ret '================================================== 'Set our Global Objects '================================================== Set obj_MarcEdit=GetObject(,"MarcEdit.Application") Set fso=CreateObject("scripting.filesystemobject") str_Source=fso.GetTempName str_Dest = fso.GetTempName tmp_ret=obj_MarcEdit.SaveText(str_Source) msgbox "Beginning to process text...Please wait", vbokonly, "III_Fix" tmp_ret=CorrectFiles() tmp_ret=obj_MarcEdit.SetText(str_Dest) set obj_MarcEdit=nothing fso.DeleteFile (str_Source) fso.DeleteFile (str_Dest) msgbox "File has been processed.", vbokonly, "MarcEdit" wscript.quit Function CorrectFiles() Dim str_Data Dim str_001 Dim Marc_String Dim tmp_array Dim tmp_string Set myfile(0)=fso.OpenTextfile(str_Source, ForReading) Set myfile(1)=fso.OpenTextfile(str_Dest, 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) 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 myfile(1).write Marc_String & vbcrlf Marc_string="" 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 Marc_String=Marc_String & "=001 1\$a" & Mid(str_Data, Instr(str_data, "=001 ") + Len("=001 ")) & vbcrlf bool_Print_Error=true end if 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 End Function