' MacroName: RecordMarc ' MacroDescription: Add "###marc" and today's date to a bib. record's 999 line ' Macro written by: Joel Hahn, Niles Public Library District Sub main 'Change the following line to what it should be for your 'library: Agency$ = "xxxmarc" dim CS as Session set CS = CurrentSession Dim nTimeOut as Integer ' The default timeout for each command is 3 minutes. ' Increase this value if your host requires more time ' for each command. nTimeOut = 180 'Set up datestamp information Today0$=Date$ Today1$=Right(Today0$, 2) Today2$=Left(Today0$, 2) Today3$=Mid(Today0$, 4, 2) Today$=Today1$+Today2$+Today3$ 'Check whether macro was triggered from within a MARC record 'or from a selected record on a Brief Titles list (and 'if so, get into the MARC record) CS.GetTextInRegion MarcTest$, 3, 32, 3, 37 If Left(Trim(MarcTest$), 4)<>"MARC" Then RunMacro "CCS!ShiftF7" 'CS.Wait 2 CS.Receive nTimeout, "[?25h" End If 'If the cursor is not currently in the Tag column of the 'MARC display, move it there cc=CS.CursorColumn If cc=21 or cc=22 Then CS.Send "\x09\x09\x09" CS.Receive 5, "[?25l" ElseIf cc=25 Then CS.Send "\x09\x09" CS.Receive 5, "[?25l" ElseIf cc>=27 Then CS.Send "\x09" CS.Receive 5, "[?25l" End If 'Find out how many rows are in the record, and which of 'those rows the cursor is currently on CS.GetTextInRegion LinNums$, 3, 1, 3, 80 place=Instr(LinNums$, "Line") LinNums$=Right(LinNums$, Len(LinNums$)-place) place2=Instr(LinNums$, "of") CurLin=Val(Mid(LinNums$, 4, place2-4)) TotalLines=Val(Mid(LinNums$, place2+2, Len(LinNums$)-place2)) 'If the cursor is not already on the last line, send 'down arrows until it is If CurLin<>TotalLines Then Do CS.Send chr(27)+"[B" CS.Receive nTimeout, chr(27) + "[?25h" CurLin=CurLin+1 Loop Until CurLin=TotalLines End If 'Tab over to the data field, then go to the end of the line CS.Send chr(9) + chr(9) + chr(9) + chr(9) 'Old shortcut to the end of the line; only works if '910 (ATKey) is the previous line, which isn't always the 'case. Go left (up to the end of the ATKey), down (into 'the middle of "PRELIMINARY DATA", then over the few 'characters to the end of the line 'CS.Send chr(27)+"[D"+chr(27)+"[B" 'CS.Send chr(27)+"[C"+chr(27)+"[C"+chr(27)+"[C"+chr(27)+"[C" For i=1 to 16 CS.Send chr(27)+"[C" Next i CS.Receive nTimeout, chr(27) + "[?25h" 'Last check-- by this point, the cursor should be at the 'end of the 999 line; if not, then there isn't a 999 line 'in the record and one must be added before proceeding CursRow=CS.CursorRow CS.GetTextInRegion PrelimDat$, CursRow, 27, CursRow, 42 If PrelimDat$<>"PRELIMINARY DATA" Then CS.GetTextInRegion InsOvr$, 21, 70, 21, 75 If InsOvr$="OVERST" Then CS.Send "\x1B[K" CS.Receive nTimeout, chr(27) + "[?25h" End If CS.Send chr(27)+"[A"+Chr(9)+Chr(13)+"999 aPRELIMINARY DATA" End If 'Add the intent to interface, with today's datestamp CS.Send " "+Agency$+" "+Today$ CS.Receive nTimeout, chr(27) + "[?25h" 'Store the changes to the record CS.Send chr(1) + "J" '[F10] CS.Receive nTimeout, chr(27) + "[?25h" 'The macro stops here to allow the user to back out of the 'store function, just in case the macro doesn't work 'properly, or if the user had selected the wrong record 'To fully automate the function, so that it's possible to 'include the intent to interface from a selected Brief 'Title record and then automatically return to the Brief 'Title list, remove the comment mark from the following 'lines: 'CS.Send " " 'CS.Send chr(1) + "C" '[F3] End Sub