' MacroName: LastSystem ' MacroDescription: Take a file of Last System Copy ATKeys, ' delete the CCS records, and make a file of the "deleted" ' OCLC numbers ' Written by: Joel Hahn, Niles Public Library District Type ATKey ATKey As String * 12 CRLF As String * 2 End Type sub main Dim KeyIn as ATKey Dim CS as Session Set CS = CurrentSession filename$="C:\clsi\lastsys.txt" filenum%=FreeFile lenfile=FileLen(filename$) numrecs=lenfile/14 Open filename$ for Random As filenum% Len=14 pos=1 Do Until pos>numrecs Get #filenum%, pos, KeyIn If KeyIn.ATKey=" " Then Goto DoNext2 CS.Send KeyIn.AtKey + Chr(13) CS.Receive 10, "[?25h" CS.GetTextInRegion CheckScreen$, 7, 20, 7, 79 If InStr(1, CheckScreen$, "| There are no satisfiers for this |")>0 or InStr(1, CheckScreen$, "There are no satisfiers for this")>0 Then 'MsgBox "No need to delete" CS.Send " " CS.Receive 10, "[?25h" Goto DoNext End If CS.GetTextInRegion SysCopies$, 10, 38, 10, 46 CS.GetTextInRegion LocCopies$, 11, 38, 11, 46 CS.GetTextInRegion SysOrders$, 10, 71, 10, 79 CS.GetTextInRegion LocOrders$, 11, 71, 11, 79 SysCopies$=Trim(SysCopies$) LocCopies$=Trim(LocCopies$) SysOrders$=Trim(SysOrders$) LocOrders$=Trim(LocOrders$) If SysCopies$="0" And LocCopies$="0" And SysOrders$="0" And LocOrders$="0" Then If Right(KeyIn.ATKey, 3)="000" Then CS.Send Chr(1)+"g" CS.Receive 10, "[?25h" Else 'Volume record; not base record CS.Send Chr(1)+"G" CS.Receive 10, "[?25h" 'MsgBox "Delete would go here" CS.Send chr(1)+"O" CS.Receive 15, "" ' "[?25h" CS.Send "1" CS.Receive 15, "continue." ' "[?25h" CS.Send " " CS.Receive 15, "[?25h" CS.Send Chr(1)+"d" CS.Receive 15, "[?25h" CS.Send Left(KeyIn.ATKey, 9)+"000\r" CS.Receive 15, "[?25h" CS.GetTextInRegion Volumes$, 10, 38, 10, 46 CS.GetTextInRegion SysOrders$, 10, 71, 10, 79 CS.GetTextInRegion LocOrders$, 11, 71, 11, 79 Volumes$=Trim(Volumes$) SysOrders$=Trim(SysOrders$) LocOrders$=Trim(LocOrders$) If Volumes$="0" and SysOrders$="0" and LocOrders$="0" Then CS.Send Chr(1)+"g" Else 'MsgBox "No need to delete" Goto DoNext End If End If CS.GetTextInRegion CheckScreen, 10, 24, 10, 60 If InStr(1,CheckScreen, "This record is currently locked by") Then 'MsgBox "Someone else is using the record; please try again later." CS.Send " " Goto DoNext End If CS.GetTextInRegion CheckTag, 7,17,7,19 If CheckTag<>"001" Then Goto BadRec End If CS.GetTextInRegion OCLCNum$, 7,27,7,56 OCLCNum$=Trim(OCLCNum$) If InStr(1,OCLCNum$, "Fix me") Then Goto BadRec End If If Left(OCLCNum$,3)="cls" Then Goto BadRec ElseIf Left(OCLCNum$,3)="ocm" Then OCLCNum$=Right(OCLCNum$, Len(OCLCNum$)-3) End If If Len(OCLCNum$)<>8 Then Goto BadRec End If If Val(Left(OCLCNum$,3))>300 Then i=9 Do CS.GetTextInRegion CheckTag,i,17,i,19 If CheckTag="010" Then CS.GetTextInRegion CheckLN$, i,30,i,56 CheckLN$=Trim(CheckLN$) Exit Do End If i=i+9 Loop While i<15 If OCLCNum$=CheckLN$ Then Goto BadRec End If ElseIf Val(Left(OCLCNum$,3))>600 Then Goto BadRec End If 'Store OCLC number in a file, to be batch-deleted later filename2$="G:\DELETE.TXT" filenum2%=FreeFile Open filename2$ For Append As filenum2% Print #filenum2%, OCLCNum$ Close filenum2% 'CS.Send chr(1)+"C" '[F3] 'CS.Receive 10, "[?25h" BadRec: 'Section REMmed out; if record is "bad", almost always, there's 'no OCLC holdings to delete; so just delete the record and be 'done with it ' MsgBox "Please put the printout aside, to be deleted manually." ' CS.Send chr(1)+"C" '[F3] DeleteRecord: 'MsgBox "Delete would go here" CS.Send chr(1)+"O" CS.Receive 15, "" ' "[?25h" CS.Send "1" CS.Receive 15, "continue." ' "[?25h" CS.Send " " CS.Receive 15, "[?25h" DoNext: KeyIn.ATKey=" " Put #filenum%, pos, KeyIn CS.Send Chr(1)+"d" CS.Receive 10, "[?25h" Else 'MsgBox "No need to delete" KeyIn.ATKey=" " Put #filenum%, pos, KeyIn CS.Send Chr(1)+"d" CS.Receive 10, "[?25h" End If DoNext2: pos=pos+1 Loop close filenum% Kill filename$ end sub