' MacroName: SecondDelete ' MacroDescription: Delete withdrawn items from the c-fly record ' Created by: Joel Hahn, Niles Public Library District. 'Note: In order to work, you must first type (or scan) all of the barcodes 'you wish to delete into a file called C:\DODELETE.TXT sub main Dim CS as Session Set CS = CurrentSession Dim nContinue as Integer Dim nTimeOut as Integer Dim BarcodeOut as String Dim Barcode as String Dim newline as String On Error Resume Next ' The default timeout for each command is 1 minute. ' Increase this value if your host requires more time ' for each command. nTimeOut = 60 CS.Send Chr(1) + "d" For i=1 to 10 CS.Send Chr(27)+"[B" CS.Receive nTimeout, chr(27) + "[?25h" Next i filename$="C:\DoDelete.txt" filenum%=FreeFile lenfile=FileLen(filename$) numrecs=lenfile/16 newline=Chr(13)+Chr(10) Open filename$ for Input As filenum% x=1 : bo=1 Do Until x=Lof(filenum%) Line Input #filenum%, Barcode If Barcode=" " or Barcode="" Then Goto DoNext2 CS.Send Barcode CS.Send Chr(13) CS.Receive nTimeout, chr(27) + "[?25h" '***Timing error may occur here 'CS.Receive NTimeout, chr(27) + "[?25h" bo=0 CS.GetTextInRegion CheckScreen$, 10, 11, 10, 50 If InStr(1, CheckScreen$, "Item not found.")>0 Then 'MsgBox "No need to delete" CS.Send " " ' Wait for response from host. CS.Receive nTimeout, chr(27) + "[?25h" CS.Send Chr(27)+"[A" 'CS.Receive nTimeout, Chr(27) + "[?25h" BarcodeOut=BarcodeOut+" "+newline bo=1 Goto DoNext2 ElseIf InStr(1, CheckScreen$, "Invalid barcode.")>0 Then 'MsgBox "No need to delete" CS.Send " " CS.Receive nTimeout, chr(27) + "[?25h" CS.Send Chr(27)+"[A" 'CS.Receive nTimeout, chr(27) + "[?25h" 'BarcodeOut=BarcodeOut+Barcode+newline 'bo=0 Goto DoNext2 End If CS.GetTextInRegion CheckScreen$, 9, 30, 9, 49 If InStr(1,CheckScreen, "locked by someone") Then 'MsgBox "Someone else is using the record; please try again later." CS.Send " " Goto DoNext2 End If CS.Send chr(1) + "O" CS.Receive nTimeout, chr(27) + "[15;27H" CS.Send "1" CS.Receive nTimeout, chr(27) + "[9;30H" + chr(7) CS.Send chr(13) CS.Wait 6 CS.Send chr(13) CS.Receive nTimeout, chr(27) + "[?25h" filenum2%=FreeFile Filename2$="C:\DoDeleteout.txt" Open Filename2$ for Output as filenum2% Print #filenum2%, Barcode Close filenum2% DoNext: BarcodeOut=BarcodeOut+" "+newline bo=1 'KeyIn.Barcode=" " 'Put #filenum%, pos, KeyIn CS.Send chr(1) + "C" CS.Receive nTimeout, chr(27) + "[?25h" DoNext2: if bo=0 Then BarcodeOut=BarcodeOut+Barcode+newline bo=0 CS.Send chr(4) CS.Receive nTimeout, chr(27) + "[?25h" x=x+1 y=Seek(filenum%) If y>Lof(filenum%) then x=Lof(filenum%) Else Seek filenum%,y End If Loop close filenum% Open filename$ for Output as filenum% Print #filenum%, BarcodeOut Close filenum% MsgBox "Done!" end sub