' MacroName: ChangeByBarcode ' MacroDescription: ChangeByBarcode ' Written by: Joel Hahn, Niles Public Library District '$Include: "CCS-2!ChangeSubs" 'Declare Function WorkForm() 'Declare Sub GenericChangeCallNum(CallNum$) 'Declare Sub NewBook(CallNum$) sub main dim CS as session set CS = CurrentSession 'On Error Goto ErrHand '! Changes item records; doesn't use a pre-created barcode list Dim nTimeOut as Integer ' The default timeout for each command is 1 minute. ' Increase this value if your host requires more time ' for each command. nTimeOut = 60 InitChoice: Begin Dialog ChoiceDialog 211, 45, "Initial Choice" OkButton 164, 8, 40, 14 CancelButton 164, 24, 40, 14 OptionGroup .WkFmYN OptionButton 8, 12, 156, 10, "Use Workform/Format Change/Add/Del./etc.", .WkFmY OptionButton 8, 24, 114, 10, "Add to/Delete from Call Number", .WkFmN End Dialog Dim ChoiceDia As ChoiceDialog CD=Dialog(ChoiceDia) If CD=0 Then Goto done WkFmYN=ChoiceDia.WkFmYN SecondChoice: If WkFmYN=0 Then 'If only changing call numbers, but not using the built-in 'workform to do so, comment out the following four lines. WkFm=WorkForm If WkFm="" Then Goto done NBLTPT=Left(WkFm, 2) : WkFm=Right(WkFm, Len(WkFm)-2) NB=Left(NBLTPT, 1) : LTPT=Right(NBLTPT, 1) End If If WkFmYN=1 Then 'Don't use workform AddDelete: Begin Dialog AddDelete 197, 118, "Add or Delete" OptionGroup .AddDel OptionButton 9, 4, 116, 10, "Add to start of Adult call number", .ADAdd OptionButton 9, 19, 118, 10, "Add after 'J/' of Juv. call number", .ADAddJ OptionButton 9, 40, 132, 10, "Delete from start of Adult call number", .ADDel OptionButton 8, 53, 126, 10, "Delete after 'J/' of Juv. call number", .ADDelJ OptionButton 8, 72, 33, 10, "Delete", .ADAD OptionButton 8, 86, 33, 10, "Delete", .ADADJ TextBox 127, 11, 63, 12, .Add Text 9, 28, 188, 8, "______________________________________________" TextBox 142, 44, 12, 12, .Del Text 157, 46, 39, 8, "characters" Text 9, 60, 188, 8, "______________________________________________" TextBox 41, 71, 12, 12, .Del2 Text 57, 73, 67, 8, "characters and add" TextBox 130, 71, 52, 12, .Add2 TextBox 41, 85, 12, 12, .Del2J Text 57, 87, 94, 8, "characters after J/ and add" TextBox 151, 85, 36, 12, .Add2J OkButton 8, 100, 40, 14 CancelButton 52, 100, 40, 14 End Dialog Dim AddDel as AddDelete AD=Dialog(AddDel) If AD=0 Then Goto InitChoice AddD=AddDel.AddDel If (AddD="0" or AddD="1") and AddDel.Add="" Then MsgBox "You need to fill in the proper box" Goto AddDelete ElseIf (AddD="2" or AddD="3") and AddDel.Del="" Then MsgBox "You need to fill in the proper box" Goto AddDelete ElseIf AddD="4" and (AddDel.Add2="" or AddDel.Del2="") Then MsgBox "You need to fill in the proper boxes" Goto AddDelete ElseIf AddD="5" and (AddDel.Add2J="" or AddDel.Del2J="") Then MsgBox "You need to fill in the proper boxes" Goto AddDelete End If End If 'CS.Send chr(1)+"d"+chr(27)+"[B"+chr(27)+"[A"+chr(27)+"[A"+chr(27)+"[A" 'chr(27)+"[A" CS.Send chr(1)+"d" For adown = 1 to 10 CS.Send chr(27)+"[B" Next adown ' Wait for response from host. CS.Receive nTimeOut, "[?25h" z=1 WhichButton=1 Do Until WhichButton=0 Begin Dialog Barcodes 66, 37, "Barcode Entry" TextBox 2, 2, 60, 12, .BCode OkButton 2, 17, 28, 15, .OK CancelButton 33, 17, 29, 15, .Cancel End Dialog Dim BCodeDialog As Barcodes WhichButton=Dialog(BCodeDialog) If WhichButton=0 Then Goto SecondChoice ' done barcode$=BCodeDialog.BCode CS.Send barcode$+chr(13) ' CS.Receive nTimeout, "Note 2:" '"continue." CS.Receive nTimeout, chr(27) + "[?25h" CS.GetTextInRegion InvalidCheck$, 10, 11, 10, 30 If InStr(InvalidCheck$, "Invalid") > 0 Then CS.Send " " ' Wait for response from host. CS.Receive nTimeout, chr(27) + "[?25h" MsgBox "Barcode " & barcode$ & " is not valid." Goto ClearField Elseif InStr(InvalidCheck$, "not found") > 0 Then CS.Send " " ' Wait for response from host. CS.Receive nTimeout, chr(27) + "[?25h" MsgBox "Barcode " & barcode$ & " is not on file." Goto ClearField ' Else ' Goto SaveScreen End If CS.GetTextInRegion ATKey$, 5, 68, 5, 76 CS.GetTextInRegion CallNum$, 10, 20, 10, 67 CallNum$="1"+RTrim(CallNum$) CS.GetTextInRegion Cost$, 12, 59, 12, 70 Cost$=Trim(Cost$) If WkFmYN=0 Then 'Use Workform '*************************************************************** 'If only changing call numbers, and not using the built-in 'workform, comment out the following line CS.Send WkFm 'Insert changes to be made to the call number here. 'If you are changing call numbers but are using the built-in 'workform to do so, comment out these lines. If NB=1 Then Call NewBook(CallNum$) If LTPT=1 Then Call GenericChangeCallNum(CallNum$) 'End If 'If WkFmYN=1 Then Else CallNum$=Right(CallNum$, Len(CallNum$)-1) Select Case AddD Case 0 AddText$=AddDel.Add If Right(AddText$, 1)<>"/" Then AddText$=AddText$+"/" NewCall$=AddText$+CallNum$ Case 1 AddText$=AddDel.Add If Right(AddText$, 1)<>"/" Then AddText$=AddText$+"/" NewCall$="J/"+AddText$+Right(CallNum$, Len(CallNum$)-2) Case 2 NumDel=Val(AddDel.Del) NewCall$=Right(CallNum$, Len(CallNum$)-NumDel) Case 3 NumDel=Val(AddDel.Del) NewCall$="J/"+Right(CallNum$, Len(CallNum$)-(NumDel+2)) End Select DnArr$="" For DownArrows=1 to 4 DnArr$=DnArr$+chr(27)+"[B" 'Down Arrows Next DownArrows CS.Send DnArr$+chr(4) CS.Send NewCall$ ' Wait for response from host. CS.Receive nTimeout, chr(27) + "[?25h" End If 'If Cost$="$0.00" then Msgbox "Cost needs to be added for " & ATKey$ & "." '*************************************************************** CS.Send chr(1) + "J" '[F10] CS.Receive nTimeOut, "[9;11H"+chr(27)+"[?25h" 'CS.Wait 2 CS.Send " " CS.Receive nTimeOut, "System" ' "[?25h" GoBack: CS.Send chr(1) + "C" '[F3] CS.Receive 10, "" ' "[?25l" ClearField: CS.Send chr(4) 'CTRL-D CS.Receive nTimeOut, "[?25h" 'CS.Receive 1, "[?25l" z=z+1 Loop Goto done 'ErrHand: ' If Erl=47 Then ' MsgBox barcode$ & " is not valid or does not exist." ' CS.Send " " ' CS.Receive nTimeOut, "[?25l" ' Resume ClearField ' ElseIf Erl=90 Then ' Resume Next ' Else ' MsgBox "Error(" & Erl & ") " & Err & ": " & Error$ ' Resume done ' End If done: end sub